﻿#include "stdafx.h"
#include "DrawCurve.h"
#include "HZData.h"

CDrawCurve::CDrawCurve()
{
	m_nRedNo = -1;
	m_rtPic = 0;

	m_fYGap = 0;			//y轴间距
	m_fYDownGap = 0;		//y轴下桩间距
	m_fXGap = 0;			//x轴间距
	m_fYMax = 0;			//Y轴最大值
	m_fYDowmMax = 0;		//Y轴下桩最大值
	m_fYMin = 0;			//Y轴最小值 0
	m_fXMin = 0;			//X轴最小值 0

	m_ZphPos = POS_Null;
}


CDrawCurve::~CDrawCurve()
{
}

int CDrawCurve::GetLineType()
{
	int nLine = PS_DOT;
	if (g_CoordSet.nLineType)
	{
		nLine = PS_SOLID;
	}
	return nLine;
}

//画纵坐标
void CDrawCurve::DrawV(CURVE_TYPE Curve_Type, CDC *memdc, CRect rtCurve, CRect &rtPic, float &fYGap, float &fMin, BOOL bPrint)
{
	if (!g_bInitData)
	{
		return;
	}
	HZ_PROJECT_INFO	Pro_Info = CHZData::GetInstance()->m_HZProInfo;
	CPen pen, *OldPen = NULL;
	CBrush brush, *OldBrush = NULL;
	CString strVal(L""), strYUnit(L"");
	float fMax = 0;		//纵坐标最大值
	vector<float> vMgLoadVal; //锚杆纵坐标拉力值
	if (Curve_Type == CU_s_lgt)
	{
		if (!GetLgtYMaxMinVal(fMax, fMin))
		{
			fMax = 1;
			fMin = 0;
		}
		strYUnit = g_strCurveUnitY[2];
	}
	else if (Curve_Type == CU_s_lgQ)
	{
		if (!GetSlgQYMaxMinVal(fMax, fMin))
		{
			fMax = 1;
			fMin = 0;
		}
		strYUnit = g_strCurveUnitY[1];
	}
	else if (Curve_Type == CU_Q_s)
	{
		if (!GetQSYMaxMinVal(fMax, fMin))
		{
			fMax = 1;
			fMin = 0;
		}
		strYUnit = g_strCurveUnitY[0];
	}
// 	else if (Curve_Type == CU_MG_Q_s || Curve_Type == CU_MG_Se_Q_Sp)
// 	{
// 		if (!GetMgQSYMaxMinVal(vMgLoadVal, fMax, fMin))
// 		{
// 			fMax = 1;
// 			fMin = 0;
// 		}
// 		strYUnit = g_strCurveUnitY[0];
// 	}
	else if (Curve_Type == CU_ZPH_QQS)
	{
		if (!GetZphQQSYMaxMinVal(fMax, fMin))
		{
			fMax = 1;
			fMin = 0;
		}
		strYUnit = g_strCurveUnitY[0];
	}

	//获取位移长度最长的值
	strVal.Format(L"%.1f", fMax);
	CSize szFont;
	szFont = memdc->GetTextExtent(strVal);
	int nLenMax = 0;
	nLenMax = szFont.cx;
	strVal.Format(L"%.1f", fMin);
	szFont = memdc->GetTextExtent(strVal);
	nLenMax = nLenMax < szFont.cx ? szFont.cx : nLenMax;
	int nW = nLenMax + 15;
	int nH = 10;
	if (bPrint)
	{
		nW = nLenMax + FONT_TOP;
		nH = FONT_TOP;
	}

	int nToLeft = rtCurve.left + nW;	//画图左侧
	int nToTop = rtCurve.top + nH;		//画图上方
	//画图的宽度和高度
	int nWidth = rtCurve.Width() - 2 * nW;			//画图区域宽度
	int nHight = rtCurve.Height() - 2 * nH;			//画图区域高度
	
	//刻度高度
	int nTitleHig = KEDU;
	int nKeduHig = KEDU;	//长度
	if (bPrint)
	{
		nTitleHig = KEDU_PRINT;
		nKeduHig = KEDU_PRINT;	//长度
	}

	
	//CU_ZPH_QQS 始终向下
	if (Curve_Type == CU_ZPH_QQS)
	{
		nToTop += (szFont.cy + nKeduHig * 2);
	}
	else if (!g_CoordSet.chUp)//预留刻度区域
	{
		nToTop += (szFont.cy + nKeduHig * 2);
	}
	
	nHight -= (szFont.cy + nKeduHig * 2);

	//画坐标轴
	brush.CreateSolidBrush(RGB(0, 0, 0));
	memdc->SelectObject(&brush);
	//横坐标
	CPoint pt = 0;
	pt.x = nToLeft;
	//CU_ZPH_QQS 始终向下
	if (Curve_Type == CU_ZPH_QQS)
	{
		pt.y = nToTop;
	}
	else if (g_CoordSet.chUp)
	{
		pt.y = nToTop + nHight;
	}
	else
	{
		pt.y = nToTop;
	}	
	
	memdc->MoveTo(pt);
	pt.x = nToLeft + nWidth;
	memdc->LineTo(pt);

	int nL = ARRAW_LEN;
	if (bPrint)
	{
		nL *= 7;
	}
	//箭头
	memdc->MoveTo(pt);
	memdc->LineTo(pt.x - nL, pt.y + nL / 2);
	memdc->MoveTo(pt);
	memdc->LineTo(pt.x - nL, pt.y - nL / 2);

// 	if (Curve_Type == CU_MG_Se_Q_Sp) //左右双箭头
// 	{
// 		pt.x = nToLeft;
// 		memdc->MoveTo(pt);
// 		memdc->LineTo(pt.x + nL, pt.y + nL / 2);
// 		memdc->MoveTo(pt);
// 		memdc->LineTo(pt.x + nL, pt.y - nL / 2);
// 	}
	//
	//竖坐标
	pt.x = nToLeft;
// 	if (Curve_Type == CU_MG_Se_Q_Sp) //总坐标在中心轴
// 	{
// 		pt.x = nToLeft + nWidth / 2;
// 	}
	pt.y = nToTop + nHight;
	memdc->MoveTo(pt.x, nToTop + nHight);
	pt.y = nToTop;
	memdc->LineTo(pt.x, nToTop);

	if (Curve_Type == CU_ZPH_QQS)
	{
		memdc->MoveTo(pt.x, nToTop + nHight);
		memdc->LineTo(pt.x - nL / 2, nToTop + nHight - nL);
		memdc->MoveTo(pt.x, nToTop + nHight);
		memdc->LineTo(pt.x + nL / 2, nToTop + nHight - nL);
	}
	else
	{
		//箭头
		if (g_CoordSet.chUp)
		{
			memdc->MoveTo(pt.x, nToTop);
			memdc->LineTo(pt.x - nL / 2, nToTop + nL);
			memdc->MoveTo(pt.x, nToTop);
			memdc->LineTo(pt.x + nL / 2, nToTop + nL);
		}
		else
		{
			memdc->MoveTo(pt.x, nToTop + nHight);
			memdc->LineTo(pt.x - nL / 2, nToTop + nHight - nL);
			memdc->MoveTo(pt.x, nToTop + nHight);
			memdc->LineTo(pt.x + nL / 2, nToTop + nHight - nL);
		}
	}
	
	

//	strVal = L"s(mm)";	//位移 毫秒
	strVal = strYUnit;
	szFont = memdc->GetTextExtent(strVal);
	
	nL = 8;
	if (bPrint)
	{
		nL *= 7;
	}
	if (Curve_Type == CU_ZPH_QQS)
	{
		memdc->TextOutW(pt.x + nL, nToTop + nHight - szFont.cy, strVal);
	}
	else
	{
		if (g_CoordSet.chUp)
		{
			memdc->TextOutW(pt.x + nL, nToTop, strVal);
		}
		else
		{
			memdc->TextOutW(pt.x + nL, nToTop + nHight - szFont.cy, strVal);
		}
	}
	
	int nToBottom = szFont.cy * 2;
	memdc->SelectObject(OldBrush);
	brush.DeleteObject();
	
	float fCha = (fMax - fMin);
	if (fCha > -EPSINON && fCha < EPSINON)
	{
		fYGap = 0;
	}
	else
	{
		fYGap = (nHight - nToBottom) / (fMax - fMin);
	}
	
	if (!bPrint)
	{
		m_fYGap = fYGap;
	}

	rtPic.left = nToLeft;
	rtPic.top = nToTop;
	rtPic.right = rtPic.left + nWidth;
	rtPic.bottom = rtPic.top + nHight;

	// 画纵坐标虚线
	float fGap = float(abs(fMax - fMin) / 10.0);

	//锚杆基本 的纵坐标 是拉力值
	int nEnd = 11;
// 	if (Curve_Type == CU_MG_Q_s || Curve_Type == CU_MG_Se_Q_Sp)
// 	{
// 		nEnd = (int)vMgLoadVal.size();
// 	}
	for (int i = 0; i < nEnd; ++i)
	{
		//画刻度
		pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
		OldPen = memdc->SelectObject(&pen);
		pt.x = rtPic.left;
		if (Curve_Type == CU_MG_Se_Q_Sp) //总坐标在中心轴
		{
			pt.x = rtPic.left + nWidth / 2;
		}
// 		if (Curve_Type == CU_MG_Q_s || Curve_Type == CU_MG_Se_Q_Sp)
// 		{
// 			if (0 == i)
// 			{
// 				if (g_CoordSet.chUp)
// 				{
// 					pt.y = int(rtPic.bottom );
// 				}
// 				else
// 				{
// 					pt.y = int(rtPic.top);
// 				}
// 			}
// 			else
// 			{
// 				if (g_CoordSet.chUp)
// 				{
// 					pt.y = int(rtPic.bottom - fYGap * (vMgLoadVal[i] - fMin));
// 				}
// 				else
// 				{
// 					pt.y = int(rtPic.top + fYGap * (vMgLoadVal[i] - fMin));
// 				}
// 			}
// 			
// 		}
// 		else
// 		{
// 				
// 		}
			
		if (Curve_Type == CU_ZPH_QQS)
		{
			pt.y = int(rtPic.top + fYGap * fGap * i);
		}
		else
		{
			if (g_CoordSet.chUp)
			{
				pt.y = int(rtPic.bottom - fYGap * fGap * i);
			}
			else
			{
				pt.y = int(rtPic.top + fYGap * fGap * i);
			}
		}

		pt.x = pt.x - nKeduHig;
		memdc->MoveTo(pt);
// 		if (Curve_Type == CU_MG_Se_Q_Sp)
// 		{
// 			memdc->LineTo(pt.x + nKeduHig * 2 + 1, pt.y);
// 		}
// 		else
// 		{
// 			memdc->LineTo(pt.x + nKeduHig, pt.y);
// 		}
		memdc->LineTo(pt.x + nKeduHig, pt.y);
		memdc->SelectObject(OldPen);
		pen.DeleteObject();
		//写刻度值
		if (i == 0)
		{
			strVal.Format(L"%.1f", fMin);
		}
		else
		{
// 			if (Curve_Type == CU_MG_Q_s || Curve_Type == CU_MG_Se_Q_Sp)
// 			{
// 				strVal.Format(L"%.1f", vMgLoadVal[i]);
// 			}
// 			else
// 			{
// 				strVal.Format(L"%.1f", fGap * i + fMin);
// 			}	
			strVal.Format(L"%.1f", fGap * i + fMin);
		}
		
		szFont = memdc->GetTextExtent(strVal);
		nL = 2;
		if (bPrint)
		{
			nL = 20;
		}
		memdc->TextOutW(pt.x - szFont.cx - nL, pt.y - szFont.cy / 2, strVal);	

		//画辅助虚线
		if (i > 0 && g_CoordSet.bCurveShow)
		{
			pen.CreatePen(PS_DOT, 1, RGB(200, 200, 200));
			OldPen = memdc->SelectObject(&pen);
			pt.x = nToLeft;
			memdc->MoveTo(pt);
			pt.x = nToLeft + nWidth;
			memdc->LineTo(pt);
			memdc->SelectObject(OldPen);
			pen.DeleteObject();
		}	
	}
	if (!bPrint)
	{
		m_rtPic = rtPic;
	}
	ClearVector(vMgLoadVal);
}


//画横坐标刻度 返回刻度区域
CRect CDrawCurve::DrawKeduVal(CURVE_TYPE Curve_Type, CDC *memdc, CRect rtPic, float fXGap, float fVal, int nKedu)
{
	CRect rt = 0;
	CPoint pt;
	CString strVal(L"");
	CSize szFont;
	pt.x = int(rtPic.left + fXGap * fVal);
	if (Curve_Type == CU_ZPH_QQS)
	{
		pt.y = rtPic.top;
	}
	else
	{
		if (g_CoordSet.chUp)
		{
			pt.y = rtPic.bottom;
		}
		else
		{
			pt.y = rtPic.top;
		}

	}
	memdc->MoveTo(pt);
	if (Curve_Type == CU_ZPH_QQS)
	{
		pt.y -= nKedu;
	}
	else
	{
		if (g_CoordSet.chUp)
		{
			pt.y += nKedu;
		}
		else
		{
			pt.y -= nKedu;
		}
	}

	memdc->LineTo(pt);
	//写刻度值
	strVal.Format(L"%.1f", fVal);

	szFont = memdc->GetTextExtent(strVal);
	rt.left = pt.x - szFont.cx / 2;
	rt.right = pt.x + szFont.cx / 2;

	if (Curve_Type == CU_ZPH_QQS)
	{
		rt.top = pt.y - szFont.cy;
	}
	else
	{
		if (g_CoordSet.chUp)
		{
			rt.top = pt.y + 2;
		}
		else
		{
			rt.top = pt.y - szFont.cy;
		}
	}
	return rt;
}


//排序
void CDrawCurve::SortVal(vector<float> vSrc, vector<float> &vfSortVal)
{
	if (!g_bInitData || vSrc.empty())
	{
		return;
	}
	vfSortVal.clear();
	vfSortVal.push_back(vSrc[0]);
	BOOL bInsert = FALSE;
	for (int i = 1; i < (int)vSrc.size(); ++i)
	{
		for (int k = 0; k < (int)vfSortVal.size(); ++k)
		{
			if (vSrc[i] <= vfSortVal[k])
			{
				vfSortVal.insert(vfSortVal.begin() + k, vSrc[i]);
				bInsert = TRUE;
				break;
			}
		}
		if (!bInsert)
		{
			vfSortVal.push_back(vSrc[i]);
		}
		bInsert = FALSE;
	}
}

// void CDrawCurve::DrawCurve_SlgQ(CDC *memdc, CRect rtCurve, BOOL bPrint)
// {
// 	if (!g_bInitData)
// 	{
// 		return;
// 	}
// 	//获取数据
// 	GetData(CU_s_lgQ);
// 	HZ_PROJECT_INFO	Pro_Info = CHZData::GetInstance()->m_HZProInfo;
// 	memdc->FillSolidRect(rtCurve, COLOR_WHITE);
// 	if (CHZData::GetInstance()->m_vDataInfo.empty())
// 	{
// 		return;
// 	}
// 	CFont font, *OldFont = NULL;
// 	if (!bPrint)
// 	{
// 		//获取字体大小
// 		SetWindowFont(font);
// 		OldFont = memdc->SelectObject(&font);
// 	}
// 	
// 	CPen pen, *OldPen = NULL;
// 	CBrush brush, *OldBrush = NULL;
// 	CRect rtPic = 0;
// 	float fYGap = 0;
// 	float fMin = 0;
// 	CSize szFont;
// 	CString strVal(L"");
// 	CPoint pt = 0;
// 	//画标题
// 	int nL = 10;
// 	if (g_CoordSet.chTitleShow)
// 	{
// 		if (bPrint)
// 		{
// 			nL = FONT_TOP;
// 		}
// 		strVal = g_strCurveTitle[CU_s_lgQ];
// 		szFont = memdc->GetTextExtent(strVal);
// 		memdc->TextOutW(rtCurve.left + rtCurve.Width() / 2 - szFont.cx / 2, rtCurve.top + nL, strVal);
// 		rtCurve.top += nL + szFont.cy;
// 	}
// 	
// 	//画纵坐标
// 	DrawV(CU_s_lgQ, memdc, rtCurve, rtPic, fYGap, fMin, bPrint);
// 
// 	
// 	int nKeduHig = KEDU;
// 	if (bPrint)
// 	{
// 		nKeduHig = KEDU_PRINT;
// 	}
// 	//
// 	strVal = g_strCurveUnitX[1];
// 	szFont = memdc->GetTextExtent(strVal);
// 	int nToRight = szFont.cx * 2;	//右侧
// 	rtPic.right -= nToRight;
// 
// 	szFont = memdc->GetTextExtent(strVal);
// 	if (g_CoordSet.chUp)
// 	{
// 		memdc->TextOutW(rtCurve.right - szFont.cx - 5, rtPic.bottom + 3, strVal);
// 	}
// 	else
// 	{
// 		memdc->TextOutW(rtCurve.right - szFont.cx - 5, rtPic.top - szFont.cy -  3, strVal);
// 	}
// 	
// 
// 	float fHMax = 0;		//横坐标最大值
// 	vector<float> vHVal;	//横坐标值 计算log后的值
// 	GetLgQValue(vHVal, fHMax);
// 	if (g_CoordSet.chUserSet)
// 	{
// 		fHMax = g_CoordSet.fXMax;
// 		fHMax = log10(fHMax);
// 	}
// 	float fXGap = 0;	//x轴间距 
// 	if (fHMax >= -EPSINON && fHMax <= EPSINON)
// 	{
// 		fXGap = 0;
// 	}
// 	else
// 	{
// 		fXGap = (rtPic.Width()) / fHMax;
// 	}
// 	if (!bPrint)
// 	{
// 		m_fXGap = fXGap;
// 	}
// 	
// 	//获取lg值
// 	//画横坐标
// 	//排序
// 	vector<float> vfSortVal;
// 	SortVal(vHVal, vfSortVal);
// 	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
// 	OldPen = memdc->SelectObject(&pen);
// 
// 	//先写最后一个数据
// 	float fVal = -1000;
// 	int nMaxNo = 0;
// 	for (int i = 0; i < (int)vfSortVal.size(); ++i)
// 	{
// 		if (fVal < vfSortVal[i])
// 		{
// 			nMaxNo = i;
// 			fVal = vfSortVal[i];
// 		}
// 	}
// 	CRect rtLastMax = DrawKeduVal(memdc, rtPic, fXGap, vfSortVal[nMaxNo], nKeduHig);
// 
// 	strVal.Format(L"%.1f", m_vlgq[nMaxNo].fLoadVal);
// 	szFont = memdc->GetTextExtent(strVal);
// 	pt.x = rtLastMax.left + rtLastMax.Width() / 2;
// 	rtLastMax.left = pt.x - szFont.cx / 2;
// 	rtLastMax.right = pt.x + szFont.cx / 2;
// 
// 	strVal.Format(L"%.1f", m_vlgq[nMaxNo].fLoadVal);
// 	memdc->TextOutW(rtLastMax.left, rtLastMax.top, strVal);
// 
// 	CRect rtLast = 0;	//上一个的区域
// 	rtLast.right = -1000;
// 	CRect rtCur = 0;		//下一个的区域
// 	for (int i = 0; i < (int)vfSortVal.size() - 1; ++i)
// 	{
// 		rtCur = DrawKeduVal(memdc, rtPic, fXGap, vfSortVal[i], nKeduHig);
// 		strVal.Format(L"%.1f", m_vlgq[i].fLoadVal);
// 		szFont = memdc->GetTextExtent(strVal);
// 		pt.x = rtCur.left + rtCur.Width() / 2;
// 		rtCur.left = pt.x - szFont.cx / 2;
// 		rtCur.right = pt.x + szFont.cx / 2;
// 
// 		if (rtCur.left > rtLast.right && rtCur.right < rtLastMax.left)
// 		{
// 			memdc->TextOutW(rtCur.left, rtCur.top, strVal);
// 			rtLast = rtCur;
// 		}
// 	}
// 	//最大值最后一个值
// 	if (g_CoordSet.chUserSet && fHMax > vfSortVal[nMaxNo])
// 	{
// 		rtCur = DrawKeduVal(memdc, rtPic, fXGap, fHMax, nKeduHig);
// 		strVal.Format(L"%.02f", g_CoordSet.fXMax);
// 		szFont = memdc->GetTextExtent(strVal);
// 		pt.x = rtCur.left + rtCur.Width() / 2;
// 		rtCur.left = pt.x - szFont.cx / 2;
// 		rtCur.right = pt.x + szFont.cx / 2;
// 		if (rtCur.left > rtLastMax.right)
// 		{
// 			memdc->TextOutW(rtCur.left, rtCur.top, strVal);
// 		}
// 	}
// 
// 	memdc->SelectObject(OldPen);
// 	pen.DeleteObject();
// 
// 	if (!bPrint)
// 	{
// 		m_fXMin = 0;
// 		m_vrtClrcle.clear();
// 	}
// 	vector<CRect> vRt;
// 	//画所有数值的点
// 	CRect rtCircle = 0;
// 	for (int i = 0; i < (int)vHVal.size(); ++i)
// 	{
// 		pt.x = int(rtPic.left + fXGap * vHVal[i]);
// 		if (g_CoordSet.chUp)
// 		{
// 			pt.y = int(rtPic.bottom - fYGap * /*abs*/(m_vlgq[i].fAllDisp - fMin));
// 		}
// 		else
// 		{
// 			pt.y = int(rtPic.top + fYGap * /*abs*/(m_vlgq[i].fAllDisp - fMin));
// 		}
// 		
// 		if (i == 0)
// 		{
// 			if (m_vlgq.size() != 1)
// 			{
// 				memdc->MoveTo(pt);
// 			}
// 		}
// 		else
// 		{
// 			//加载实现
// 			if (m_vlgq[i].nJiaZaiOrXieZai == LOADOFF_VALUE)
// 			{
// 				break;
// 			}
// 
// 			pen.CreatePen(PS_SOLID, 1, g_CoordSet.clrLoad);
// 			OldPen = memdc->SelectObject(&pen);
// 
// 			memdc->LineTo(pt);
// 
// 			memdc->SelectObject(OldPen);
// 			pen.DeleteObject();
// 		}
// 		if (m_nRedNo == i)
// 		{
// 			nL = CIRCLE_RED_W;
// 			if (bPrint)
// 			{
// 				nL = CIRCLE_RED_W * 5;
// 			}
// 			rtCircle.left = pt.x - nL;
// 			rtCircle.top = pt.y - nL;
// 			rtCircle.right = pt.x + nL;
// 			rtCircle.bottom = pt.y + nL;
// 		}
// 		else
// 		{
// 			nL = CIRCLE_W;
// 			if (bPrint)
// 			{
// 				nL = CIRCLE_W * 5;
// 			}
// 			rtCircle.left = pt.x - nL;
// 			rtCircle.top = pt.y - nL;
// 			rtCircle.right = pt.x + nL;
// 			rtCircle.bottom = pt.y + nL;
// 		}
// 		vRt.push_back(rtCircle);
// 	}
// 	if (!bPrint)
// 	{
// 		m_vrtClrcle = vRt;
// 	}
// 	//画圆
// 	for (int i = 0; i < (int)vRt.size(); ++i)
// 	{
// 		if (m_nRedNo == i)
// 		{
// 			brush.CreateSolidBrush(COLOR_RED);
// 		}
// 		else
// 		{
// 			brush.CreateSolidBrush(g_CoordSet.clrSample);
// 		}
// 		OldBrush = memdc->SelectObject(&brush);
// 		//画圆
// 		memdc->Ellipse(vRt[i]);
// 		memdc->SelectObject(OldBrush);
// 		brush.DeleteObject();
// 	}
// 	if (!bPrint)
// 	{
// 		memdc->SelectObject(OldFont);
// 		font.DeleteObject();
// 	}
// }

// void CDrawCurve::DrawCurve_Slgt(CDC *memdc, CRect rtCurve, BOOL bPrint)
// {
// 	if (!g_bInitData)
// 	{
// 		return;
// 	}
// 	//获取数据
// 	GetData(CU_s_lgt);
// 	HZ_PROJECT_INFO	Pro_Info = CHZData::GetInstance()->m_HZProInfo;
// 	memdc->FillSolidRect(rtCurve, COLOR_WHITE);
// 	if (CHZData::GetInstance()->m_vDataInfo.empty())
// 	{
// 		return;
// 	}
// 	CFont font, *OldFont = NULL;
// 	if (!bPrint)
// 	{
// 		//获取字体大小
// 		SetWindowFont(font);
// 		OldFont = memdc->SelectObject(&font);
// 	}
// 	
// 	CPen pen, *OldPen = NULL;
// 	CBrush brush, *OldBrush = NULL;
// 	CRect rtPic = 0;
// 	float fYGap = 0;
// 	float fMin = 0;
// 	CSize szFont;
// 	CString strVal(L"");
// 	CPoint pt = 0;
// 
// 	//画标题
// 	int nL = 10;
// 	if (g_CoordSet.chTitleShow)
// 	{
// 		if (bPrint)
// 		{
// 			nL = FONT_TOP;
// 		}
// 		strVal = g_strCurveTitle[CU_s_lgt];
// 		szFont = memdc->GetTextExtent(strVal);
// 		memdc->TextOutW(rtCurve.left + rtCurve.Width() / 2 - szFont.cx / 2, rtCurve.top + nL, strVal);
// 		rtCurve.top += nL + szFont.cy;
// 	}
// 	
// 	//画纵坐标
// 	DrawV(CU_s_lgt, memdc, rtCurve, rtPic, fYGap, fMin, bPrint);
// 
// 
// 	int nKeduHig = KEDU;
// 	if (bPrint)
// 	{
// 		nKeduHig = KEDU_PRINT;
// 	}
// 
// 	int nToRight = szFont.cx * 2;	//右侧
// 	rtPic.right -= nToRight;
// 	
// 	strVal = g_strCurveUnitX[2];
// 	szFont = memdc->GetTextExtent(strVal);
// 	if (g_CoordSet.chUp)
// 	{
// 		memdc->TextOutW(rtCurve.right - szFont.cx - 5, rtPic.bottom + 3, strVal);
// 	}
// 	else
// 	{
// 		memdc->TextOutW(rtCurve.right - szFont.cx - 5, rtPic.top - szFont.cy - 3, strVal);
// 	}
// 
// 	float fHMax = 0;		//横坐标最大值
// 	vector<float> vHVal;	//横坐标值 计算log后的值
// 	GetLgtValue(vHVal, fHMax);
// 	float fXGap = 0;	//x轴间距 
// 	if (fHMax != 0)
// 	{
// 		fXGap = (rtPic.Width()) / fHMax;
// 	}
// 	if (!bPrint)
// 	{
// 		m_fXGap = fXGap;
// 	}
// 	
// 	//获取lg值
// 	//画横坐标
// 	//排序
// 	vector<float> vfSortVal;
// 	SortVal(vHVal, vfSortVal);
// 	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
// 	OldPen = memdc->SelectObject(&pen);
// 
// 	//先写最后一个数据
// 	float fVal = -1000;
// 	int nMaxNo = 0;
// 	for (int i = 0; i < (int)vfSortVal.size(); ++i)
// 	{
// 		if (fVal < vfSortVal[i])
// 		{
// 			nMaxNo = i;
// 			fVal = vfSortVal[i];
// 		}
// 	}
// 	CRect rtLastMax = 0;
// 	if (!vfSortVal.empty())
// 	{
// 		rtLastMax = DrawKeduVal(memdc, rtPic, fXGap, (vfSortVal[nMaxNo] - vfSortVal[0]), nKeduHig);
// 		strVal.Format(L"%d", m_vlgt[nMaxNo].nTime);
// 		szFont = memdc->GetTextExtent(strVal);
// 		pt.x = rtLastMax.left + rtLastMax.Width() / 2;
// 		rtLastMax.left = pt.x - szFont.cx / 2;
// 		rtLastMax.right = pt.x + szFont.cx / 2;
// 		memdc->TextOutW(rtLastMax.left, rtLastMax.top, strVal);
// 	}
// 	
// 
// 	CRect rtLast = 0;	//上一个的区域
// 	rtLast.right = -1000;
// 	CRect rtCur = 0;		//下一个的区域
// 	for (int i = 0; i < (int)vfSortVal.size() - 1; ++i)
// 	{
// 		rtCur = DrawKeduVal(memdc, rtPic, fXGap, (vfSortVal[i] - vfSortVal[0]), nKeduHig);
// 		strVal.Format(L"%d", m_vlgt[i].nTime);
// 		szFont = memdc->GetTextExtent(strVal);
// 		pt.x = rtCur.left + rtCur.Width() / 2;
// 		rtCur.left = pt.x - szFont.cx / 2;
// 		rtCur.right = pt.x + szFont.cx / 2;
// 
// 		if (rtCur.left > rtLast.right && rtCur.right < rtLastMax.left)
// 		{
// 			memdc->TextOutW(rtCur.left, rtCur.top, strVal);
// 			rtLast = rtCur;
// 		}
// 	}
// 
// 	memdc->SelectObject(OldPen);
// 	pen.DeleteObject();
// 
// 	if (!bPrint)
// 	{
// 		m_fXMin = 0;
// 		if (!vfSortVal.empty())
// 		{
// 			m_fXMin = vfSortVal[0];
// 		}
// 		m_vrtClrcle.clear();
// 	}
// 	vector<CRect> vRt;
// 	//画所有数值的点
// 	CRect rtCircle = 0;
// 	int nCnt = 0;
// 	for (int i = 0; i < (int)m_vLoadVal.size(); ++i)
// 	{
// 		if (m_vlgt.empty())
// 		{
// 			break;
// 		}
// 		if (!m_vlgt[0].vExist[i])
// 		{
// 			continue;
// 		}
// 		for (int k = 0; k < (int)m_vlgt.size(); ++k)
// 		{
// 			if (m_vlgt[k].vExist[i])
// 			{
// 				pt.x = int(rtPic.left + fXGap * (vHVal[k] - vfSortVal[0]));
// 				if (g_CoordSet.chUp)
// 				{
// 					pt.y = int(rtPic.bottom - fYGap * /*abs*/(m_vlgt[k].vfWeiyi[i] - fMin));
// 				}
// 				else
// 				{
// 					pt.y = int(rtPic.top + fYGap * /*abs*/(m_vlgt[k].vfWeiyi[i] - fMin));
// 				}
// 
// 				if (k == 0)
// 				{
// 					if (m_vlgt.size() != 1)
// 					{
// 						memdc->MoveTo(pt);
// 					}
// 				}
// 				else
// 				{
// 					//加载实现  卸载虚线
// 					pen.CreatePen(PS_SOLID, 1, g_CoordSet.clrLoad);
// 					OldPen = memdc->SelectObject(&pen);
// 
// 					memdc->LineTo(pt);
// 
// 					memdc->SelectObject(OldPen);
// 					pen.DeleteObject();
// 				}
// 
// 				if (m_nRedNo == nCnt)
// 				{
// 					nL = CIRCLE_RED_W;
// 					if (bPrint)
// 					{
// 						nL = CIRCLE_RED_W * 5;
// 					}
// 					rtCircle.left = pt.x - nL;
// 					rtCircle.top = pt.y - nL;
// 					rtCircle.right = pt.x + nL;
// 					rtCircle.bottom = pt.y + nL;
// 				}
// 				else
// 				{
// 					nL = CIRCLE_W;
// 					if (bPrint)
// 					{
// 						nL = CIRCLE_W * 5;
// 					}
// 					rtCircle.left = pt.x - nL;
// 					rtCircle.top = pt.y - nL;
// 					rtCircle.right = pt.x + nL;
// 					rtCircle.bottom = pt.y + nL;
// 				}
// 				vRt.push_back(rtCircle);
// 				//画圆
// 				memdc->Ellipse(rtCircle);
// 
// 				nCnt++;
// 			}			
// 		}
// 		strVal.Format(L"%.1f", m_vLoadVal[i]);
// 		if (Pro_Info.chUnit == 1)
// 		{
// 			strVal += L" kPa";
// 		}
// 		else
// 		{
// 			strVal += L" kN";
// 		}
// 		szFont = memdc->GetTextExtent(strVal);
// 		nL += 3;
// 		if (bPrint)
// 		{
// 			nL += 30;
// 		}
// 		memdc->TextOutW(pt.x + nL, pt.y - szFont.cy / 2, strVal);
// 	}
// 	if (!bPrint)
// 	{
// 		m_vrtClrcle = vRt;
// 	}
// 	//画圆
// 	for (int i = 0; i < (int)vRt.size(); ++i)
// 	{
// 		if (m_nRedNo == i)
// 		{
// 			brush.CreateSolidBrush(COLOR_RED);
// 		}
// 		else
// 		{
// 			brush.CreateSolidBrush(g_CoordSet.clrSample);
// 		}
// 		OldBrush = memdc->SelectObject(&brush);
// 		//画圆
// 		memdc->Ellipse(vRt[i]);
// 		memdc->SelectObject(OldBrush);
// 		brush.DeleteObject();
// 	}
// 	if (!bPrint)
// 	{
// 		memdc->SelectObject(OldFont);
// 		font.DeleteObject();
// 	}
// }

//获取鼠标点的当前值
void CDrawCurve::GetMouseValue(CURVE_TYPE Curve_Type, CPoint pt, float &fXVal, float &fYVal)
{
	if (!g_bInitData)
	{
		return;
	}

	if (m_fXGap >= -EPSINON && m_fXGap <= EPSINON)
	{
		fXVal = 0;
	}
	else
	{
		fXVal = (pt.x - m_rtPic.left) / m_fXGap;
	}

	if (Curve_Type == CU_ZPH_slgQ || Curve_Type == CU_ZPH_slgt || Curve_Type == CU_s_lgQ || Curve_Type == CU_s_lgt)
	{
		fXVal = (float)pow(10, fXVal + m_fXMin);
	}
	else
	{
		fXVal += m_fXMin;
	}


	if (Curve_Type == CU_ZPH_QS || Curve_Type == CU_ZPH_slgQ || Curve_Type == CU_ZPH_slgt)
	{
		if (m_ZphPos == POS_Up)
		{
			if (m_fYGap >= -EPSINON && m_fYGap <= EPSINON)
			{
				fYVal = 0 + m_fYMin;
			}
			else
			{
				fYVal = (m_rtPic.top + m_rtPic.Height() / 2 - pt.y) / m_fYGap + m_fYMin;
			}

		}
		else if (m_ZphPos == POS_Down)
		{
			if (m_fYDownGap >= -EPSINON && m_fYDownGap <= EPSINON)
			{
				fYVal = 0 + m_fYMin;
			}
			else
			{
				fYVal = (pt.y - m_rtPic.top) / m_fYDownGap + m_fYMin;
			}
		}
		else{
			fYVal = 0;
		}
	}
	else
	{
		if (m_fYGap >= -EPSINON && m_fYGap <= EPSINON)
		{
			fYVal = 0 + m_fYMin;
		}
		else
		{
			if (g_CoordSet.chUp)
			{
				fYVal = (m_rtPic.bottom - pt.y) / m_fYGap + m_fYMin;
			}
			else
			{
				fYVal = (pt.y - m_rtPic.top) / m_fYGap + m_fYMin;
			}
		}
	}
}

//获取YGap
float CDrawCurve::GetYGap(CURVE_TYPE Curve_Type)
{
	float fVal = m_fYGap;
	if (Curve_Type == CU_ZPH_QS || Curve_Type == CU_ZPH_slgQ || Curve_Type == CU_ZPH_slgt)
	{
		if (m_ZphPos == POS_Down)
		{
			fVal = m_fYDownGap;
		}
	}
	else if (Curve_Type == CU_MG_Q_s)
	{
		fVal = m_fXGap;
	}

	if (fVal >= -EPSINON && fVal <= EPSINON)
	{
		fVal = (float)0.001;
	}
	return fVal;
}

void CDrawCurve::SetPrintSet(PrintSet PrintSet, int nType)
{
	m_PrintSet = PrintSet;
	if (nType != 0)
	{
		m_PrintSet.chPrintSumTable = 0;
		m_PrintSet.chPrintLoadTable = 0;
		m_PrintSet.chPrintLoadOffTable = 0;
		m_PrintSet.chPrintOriginalTable = 0;
		m_PrintSet.chPrintConfigTable = 0;
		m_PrintSet.chPrintQQSTable = 0;

		m_PrintSet.chQs = 0;
		m_PrintSet.chSlgQ = 0;
		m_PrintSet.chSlgt = 0;
		m_PrintSet.chCurvePrintStype = 0;
		m_PrintSet.chQQs = 0;

//		m_PrintSet.chPageStyle = 0;
		if (1 == nType)
		{
			m_PrintSet.chQs = 1;
		}
		else if (2 == nType)
		{
			m_PrintSet.chSlgQ = 2;
		}
		else if (3 == nType)
		{
			m_PrintSet.chSlgt = 3;
		}
		else if (4 == nType)
		{
			m_PrintSet.chPrintSumTable = 4;
		}
		else if (5 == nType)
		{
			m_PrintSet.chPrintLoadTable = 5;
		}
		else if (6 == nType)
		{
			m_PrintSet.chPrintLoadOffTable = 6;
		}
		else if (7 == nType)
		{
			m_PrintSet.chPrintOriginalTable = 7;
		}
	}
}


//画打印预览
void CDrawCurve::DrawPrintView(CDC *pDC, CPrintInfo *pInfo)
{
	if (pInfo->m_nCurPage <= m_vPageInfo.size())
	{
		DrawPage(pDC, m_vPageInfo[pInfo->m_nCurPage - 1]);
	}
	//页眉页脚
	PrintPageNum(pDC, pInfo->m_nCurPage, m_rtPrint);
}

void CDrawCurve::DrawPage(CDC *pDC, PAGE_INFO PageInfo)
{
	switch (PageInfo.Print_Type)
	{
	case eSUM_TABLE:
		DrawSumTable(pDC, PageInfo);
		break;
	case eLOAD_TABLE:
		DrawLoadTable(pDC, PageInfo);
		break;
	case eLOADOFF_TABLE:
		DrawLoadOffTable(pDC, PageInfo);
		break;
	case eMgXQB_TABLE:
		DrawLoadTable(pDC, PageInfo);
		break;
	case eORIGINAL_TABLE:
		DrawOriginalTable(pDC, PageInfo);
		break;
	case eCONFIT_TABLE:
		DrawConfigTable(pDC, PageInfo);
		break;
	case eCURVE_QS:
		DrawQSCurve(pDC, PageInfo);
		break;
	case eCURVE_SLGQ:
		DrawSlgQCurve(pDC, PageInfo);	
		break;
	case eCURVE_SLGT:
		DrawSlgtCurve(pDC, PageInfo);
		break;
	case eCURVE_QS_SLGT:
		DrawQS_SlgtCurve(pDC, PageInfo);
		break;
	case eCURVE_SLGQ_SLGT:
		DrawSlgq_SlgtCurve(pDC, PageInfo);
		break;
	case eCURVE_ALL:
		DrawQS_Slgq_SlgtCurve(pDC, PageInfo);
		break;
	case eZphQQs_Table:
		DrawSphQQsTable(pDC, PageInfo);
		break;
	case eCurve_ZphQQs:
		DrawZphQQsCurve(pDC, PageInfo);
		break;
	default:
		break;
	}
}

//画所有曲线
void CDrawCurve::DrawQS_Slgq_SlgtCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);
	//画曲线
	PrintDraw1_2_3Curve(pDC, PageInfo.rtDraw[0], PageInfo.rtDraw[1], PageInfo.rtDraw[2]);
// 	if (g_DataType == DATA_0)
// 	{
// 		DrawCurve_Qs(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_SlgQ(pDC, PageInfo.rtDraw[1], TRUE);
// 		DrawCurve_Slgt(pDC, PageInfo.rtDraw[2], TRUE);
// 	}
// 	else if (g_DataType == DATA_3)
// 	{
// 		DrawCurve_ZphQs(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_ZphSlgQ(pDC, PageInfo.rtDraw[1], TRUE);
// 		DrawCurve_ZphSlgt(pDC, PageInfo.rtDraw[2], TRUE);
// 	}

	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画Slgq-Sglt曲线
void CDrawCurve::DrawSlgq_SlgtCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);

	//画曲线
	PrintDraw2_3Curve(pDC, PageInfo.rtDraw[0], PageInfo.rtDraw[1]);
// 	if (g_DataType == DATA_0)
// 	{
// 		DrawCurve_SlgQ(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_Slgt(pDC, PageInfo.rtDraw[1], TRUE);
// 	}
// 	else if (g_DataType == DATA_3)
// 	{
// 		DrawCurve_ZphSlgQ(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_ZphSlgt(pDC, PageInfo.rtDraw[1], TRUE);
// 	}	

	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画自平衡等效Qs曲线
void CDrawCurve::DrawZphQQsCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);
	//画曲线
	if (g_DataType == DATA_3)
	{
		DrawCurve_4(pDC, PageInfo.rtDraw[0], TRUE);
//		DrawCurve_ZphQQs(pDC, PageInfo.rtDraw[0], TRUE);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画QS-Sglt曲线
void CDrawCurve::DrawQS_SlgtCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);
	//画曲线
	PrintDraw1_3Curve(pDC, PageInfo.rtDraw[0], PageInfo.rtDraw[1]);
// 	if (g_DataType == DATA_0)
// 	{
// 		DrawCurve_Qs(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_Slgt(pDC, PageInfo.rtDraw[1], TRUE);
// 	}
// 	else if (g_DataType == DATA_1)
// 	{
// 		DrawCurve_MgQs(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_MgSeQSp(pDC, PageInfo.rtDraw[1], TRUE);
// 	}
// 	else if (g_DataType == DATA_2)
// 	{
// 		DrawCurve_SpHtY0(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_SpHY0H(pDC, PageInfo.rtDraw[1], TRUE);
// 	}
// 	else if (g_DataType == DATA_3)
// 	{
// 		DrawCurve_ZphQs(pDC, PageInfo.rtDraw[0], TRUE);
// 		DrawCurve_ZphSlgt(pDC, PageInfo.rtDraw[1], TRUE);
// 	}
	

	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画曲线表头
void CDrawCurve::DrawCueveHead(CDC *pDC, PAGE_INFO PageInfo)
{
	if (PageInfo.rtTableHead.Height() < m_nWordH)
	{
		return;
	}
	int nCnt = (PageInfo.rtTableHead.Height() + m_nWordH) / (m_nWordH * 2);
	CRect rt = PageInfo.rtTableHead;
	for (int i = 1; i <= nCnt; ++i)
	{
		pDC->MoveTo(rt.left, rt.top + m_nWordH * 2 * i);
		pDC->LineTo(rt.right, rt.top + m_nWordH * 2 * i);
	}
	//详细信息行数
	int nDataCnt = (int)CHZData::GetInstance()->m_vLoadValue.size();
	int nHeadWid = 0;	//头宽
	int nInfoWid = int(m_nWordW / 2); //简单汇总表的间隔
	int nMaxCnt = int(m_rtPrint.Width() / nInfoWid);
	nInfoWid = PageInfo.rtTableHead.Width() / nMaxCnt;
	nHeadWid = nInfoWid * 2;
	nMaxCnt -= 2;
	int nCol = 0;
	int nColSum = 0; //汇总信息行数
	if (m_PrintSet.chSimpleSum && nMaxCnt > 0)
	{
		if (nMaxCnt >= nDataCnt)
		{
			nColSum = 1;
			nMaxCnt = nDataCnt;
			nHeadWid = m_nWordW;
			nInfoWid = (PageInfo.rtTableHead.Width() - nHeadWid)/ (nMaxCnt);
		}
		else
		{
			nColSum = ((nDataCnt + nMaxCnt - 1) / nMaxCnt);
		}
		nCol += nColSum * 2;
		if (m_PrintSet.chSumLoadData)
		{
			nCol += nColSum;
		}
	}
	int nWid = PageInfo.rtTableHead.Width() / 2;
	if (m_PrintSet.CurveHeadDef.bProject)
	{
		pDC->MoveTo(rt.left + nWid, rt.top + m_nWordH * 2);
		pDC->LineTo(rt.left + nWid, rt.top + m_nWordH * 2 * (nCnt - nCol));
	}
	else
	{
		pDC->MoveTo(rt.left + nWid, rt.top);
		pDC->LineTo(rt.left + nWid, rt.top + m_nWordH * 2 * (nCnt - nCol));
	}
	for (int i = 0; i < nMaxCnt; ++i)
	{
		pDC->MoveTo(rt.left + nHeadWid + nInfoWid * i, rt.top + m_nWordH * 2 * (nCnt - nCol));
		pDC->LineTo(rt.left + nHeadWid + nInfoWid * i, rt.top + m_nWordH * 2 * nCnt);
	}
	//表头
	DrawHead(pDC, m_PrintSet.CurveHeadDef, PageInfo.rtTableHead, FALSE);
	//画简单汇总表
	if (m_PrintSet.chSimpleSum && nMaxCnt > 0)
	{
		CString strVal(L"");
		HZ_PROJECT_INFO	HZProInfo = CHZData::GetInstance()->m_HZProInfo;
		rt = PageInfo.rtTableHead;
		rt.top += m_nWordH * 2 * (nCnt - nCol);
		rt.bottom = rt.top + m_nWordH * 2;
		int nNo = 0;
		int nCnt = 0;
		int nNoCnt = 0;
		int nTop = 0;
		while (nCnt < nColSum)
		{
			//荷载
			nTop = rt.top;
			rt.left = PageInfo.rtTableHead.left;
			rt.right = rt.left + nHeadWid;
			if (0 == HZProInfo.chUnit)
			{
				strVal = L"荷载（kN）";
			}
			else
			{
				strVal = L"荷载（kPa）";
			}
			pDC->DrawTextW(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
			//本级沉降
			if (m_PrintSet.chSumLoadData)
			{
				rt.top += m_nWordH * 2;
				rt.bottom = rt.top + m_nWordH * 2;
				strVal = L"本级沉降(mm)";
				pDC->DrawTextW(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
			}
			//累计沉降
			rt.top += m_nWordH * 2;
			rt.bottom = rt.top + m_nWordH * 2;
			strVal = L"累计沉降(mm)";
			pDC->DrawTextW(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		
			rt.left += nHeadWid - nInfoWid;
			nNoCnt = 0;
			for (; nNo < (int)CHZData::GetInstance()->m_vLoadValue.size(); ++nNo)
			{
				rt.top = nTop;
				rt.bottom = rt.top + m_nWordH * 2;
				rt.left += nInfoWid;
				rt.right = rt.left + nInfoWid;
				strVal.Format(L"%.1f", CHZData::GetInstance()->m_vSummaryData[nNo].fLoadVal);
				pDC->DrawTextW(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

				//本级沉降
				if (m_PrintSet.chSumLoadData)
				{
					rt.top += m_nWordH * 2;
					rt.bottom = rt.top + m_nWordH * 2;
					strVal.Format(L"%.02f", CHZData::GetInstance()->m_vSummaryData[nNo].fDispVal);
					pDC->DrawTextW(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
				}
				//累计沉降
				rt.top += m_nWordH * 2;
				rt.bottom = rt.top + m_nWordH * 2;
				strVal.Format(L"%.02f", CHZData::GetInstance()->m_vSummaryData[nNo].fAllDisp);
				pDC->DrawTextW(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

				nNoCnt++;
				if (nNoCnt >= nMaxCnt)
				{
					nNo++;
					break;
				}
			}
			nCnt++;
			rt.top += m_nWordH * 2;
			rt.bottom = rt.top + m_nWordH * 2;
		}
	}
}

//画QS曲线
void CDrawCurve::DrawQSCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);
	//画曲线
	DrawCurve_1(pDC, PageInfo.rtDraw[0], TRUE);
// 	if (g_DataType == DATA_0)
// 	{
// 		DrawCurve_Qs(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
// 	else if (g_DataType == DATA_1)
// 	{
// 		DrawCurve_MgQs(pDC, PageInfo.rtDraw[0], TRUE);
// 	}	
// 	else if (g_DataType == DATA_2)
// 	{
// 		DrawCurve_SpHtY0(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
// 	else if (g_DataType == DATA_3)
// 	{
// 		DrawCurve_ZphQs(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画Slgq曲线
void CDrawCurve::DrawSlgQCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);
	//画曲线
	DrawCurve_2(pDC, PageInfo.rtDraw[0], TRUE);
// 	if (g_DataType == DATA_0)
// 	{
// 		DrawCurve_SlgQ(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
// 	else if (g_DataType == DATA_1)
// 	{
// 		DrawCurve_MgSeQSp(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
// 	else if (g_DataType == DATA_2)
// 	{
// 		DrawCurve_SpHY0H(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
// 	else if (g_DataType == DATA_3)
// 	{
// 		DrawCurve_ZphSlgQ(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画Slgt曲线
void CDrawCurve::DrawSlgtCurve(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"曲线图", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CRect rt = PageInfo.rtTableHead;
	rt.bottom = PageInfo.rtData.bottom;
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(rt);
	//画表头
	DrawCueveHead(pDC, PageInfo);
	//画曲线
	DrawCurve_3(pDC, PageInfo.rtDraw[0], TRUE);
// 	if (g_DataType == DATA_0)
// 	{
// 		//画曲线
// 		DrawCurve_Slgt(pDC, PageInfo.rtDraw[0], TRUE);
// 	}
// 	else if (g_DataType == DATA_3)
// 	{
// 		DrawCurve_ZphSlgt(pDC, PageInfo.rtDraw[0], TRUE);
// 	}

	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画配置信息表
void CDrawCurve::DrawConfigTable(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"配置信息表", PageInfo.rtTitle);
	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	CString strVal(L"设备配置信息表新表");
	CSize szFont;
	szFont = pDC->GetTextExtent(strVal);
	int nWid = szFont.cx;
	int nWid2 = PageInfo.rtData.Width() / 2;
	CRect rt = PageInfo.rtData;
	rt.bottom = rt.top + m_nWordH * 18;
	pDC->Rectangle(rt);
	for (int i = 1; i < 9; ++i)
	{
		pDC->MoveTo(rt.left, rt.top + m_nWordH * 2 * i);
		pDC->LineTo(rt.right, rt.top + m_nWordH * 2 * i);
	}
	pDC->MoveTo(rt.left + nWid, rt.top);
	pDC->LineTo(rt.left + nWid, rt.bottom);
	pDC->MoveTo(rt.left + nWid2 + nWid, rt.top + m_nWordH * 2);
	pDC->LineTo(rt.left + nWid2 + nWid, rt.top + m_nWordH * 6);
	pDC->MoveTo(rt.left + nWid2 + nWid, rt.top + m_nWordH * 8);
	pDC->LineTo(rt.left + nWid2 + nWid, rt.bottom);
	pDC->MoveTo(rt.left + nWid2, rt.top + m_nWordH * 2);
	pDC->LineTo(rt.left + nWid2, rt.top + m_nWordH * 6);
	pDC->MoveTo(rt.left + nWid2, rt.top + m_nWordH * 8);
	pDC->LineTo(rt.left + nWid2, rt.bottom);

	HZ_PROJECT_INFO	HZProInfo = CHZData::GetInstance()->m_HZProInfo;
	rt = PageInfo.rtData;
	rt.left += FONT_LEFT;
	//工程名称
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"工程名称", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.right;
	strVal = HZProInfo.chProjectName;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//桩编号
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"桩编号", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal = HZProInfo.chPileNum;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//桩径
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"桩径(mm)", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid  + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	if (0 == HZProInfo.chShape)
	{
		strVal.Format(L"%d", HZProInfo.nPileDiam);
	}
	else
	{
		strVal.Format(L"%d x %d", HZProInfo.nPileDiam, HZProInfo.nPileDiamW);
	}
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//桩长
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"桩长（m）", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal.Format(L"%.02f", HZProInfo.fPilelength);
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//检测日期
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"检测日期", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	strVal = HZProInfo.chTestDate;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//仪器编号
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"仪器编号", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.right;
	strVal = HZProInfo.chYiqiNum;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//千斤顶编号
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"千斤顶编号", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal = HZProInfo.chJackNum;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//千斤顶类型
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"千斤顶类型", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	strVal = g_strJackType[HZProInfo.chJackType];
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//千斤顶个数
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"千斤顶个数", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal.Format(L"%d", HZProInfo.nJackCnts);
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//千斤顶内径
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"千斤顶内径（mm）", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	strVal.Format(L"%d", HZProInfo.nJackDiam);
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//位移传感器类型
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"位移传感器类型", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal = g_strWeiyiType[HZProInfo.chWeiYiSensorType];
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//位移传感器编号
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"位移传感器编号", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	strVal = HZProInfo.chWeiYiSensorNum;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//压力传感器类型
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"压力传感器类型", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal = g_strYaliType[HZProInfo.chYaLiSensorType];
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//压力传感器编号
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"压力传感器编号", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	strVal = HZProInfo.chYaLiSensorNum;
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//承压板形状
	rt.left = PageInfo.rtData.left + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"承压板形状", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += nWid;
	rt.right = PageInfo.rtData.left + nWid2;
	strVal = g_strPlateType[HZProInfo.chPlateType];
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//承压板面积
	rt.left = PageInfo.rtData.left + nWid2 + FONT_LEFT;
	rt.right = PageInfo.rtData.left + nWid2 + nWid;
	pDC->DrawText(L"承压板面积（m²）", rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left = PageInfo.rtData.left + nWid2 + nWid + FONT_LEFT;
	rt.right = PageInfo.rtData.right;
	strVal.Format(L"%.01f", HZProInfo.fPlateArea);
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	//签名
	if (m_PrintSet.chSignInConfig)
	{
		DrawSign(pDC, PageInfo);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画原始记录表
void CDrawCurve::DrawOriginalTable(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"原始记录表", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	if (PageInfo.bFirstPage && PageInfo.rtTableHead.Height() >= m_nWordH)
	{
		DrawHead(pDC, m_PrintSet.SumHeadDef, PageInfo.rtTableHead);
	}
	if (PageInfo.rtData.Height() >= m_nWordH)
	{
		DrawOriginalData(pDC, PageInfo);
	}
	if (m_PrintSet.chSignInLoadoff)
	{
		DrawSign(pDC, PageInfo);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//写记录数据
void CDrawCurve::DrawOriginalData(CDC *pDC, PAGE_INFO PageInfo)
{
	HZ_PROJECT_INFO	HZProInfo = CHZData::GetInstance()->GetProjectInfo();
	vector<DATA_INFO> vDataInfo = CHZData::GetInstance()->GetDataInfo();
	vector<int> vWeiyi;
	for (int i = 0; i < 8; ++i)
	{
		if (HZProInfo.chChanelUsed[i] && HZProInfo.chChannelSel[i])
		{
			vWeiyi.push_back(i);
		}
	}
	//列数
	int nCol = (int)vWeiyi.size();
	nCol += 7;
	CString strVal(L"");
	CRect rt = PageInfo.rtData;
	CPoint pt;
	pt.y = PageInfo.rtData.top + m_nWordH * 2;
	int nCnt = PageInfo.nEndNo - PageInfo.nBeginNo + 1;
	rt.bottom = rt.top + (nCnt + 2) * m_nWordH * 2;
	pDC->Rectangle(rt);
	int nWid = PageInfo.rtData.Width() / nCol;
	for (int i = 0; i < nCnt; ++i)
	{
		pt.x = PageInfo.rtData.left + nWid;
		pt.y += m_nWordH * 2;
		pDC->MoveTo(pt);
		pt.x = PageInfo.rtData.right;
		pDC->LineTo(pt);
	}
	for (int i = 1; i < nCol; ++i)
	{
		if (i >= 7 && i < 7 + (int)vWeiyi.size() - 1)
		{
			pDC->MoveTo(rt.left + nWid * i, rt.top + m_nWordH * 2);
		}
		else
		{
			pDC->MoveTo(rt.left + nWid * i, rt.top);
		}
		pDC->LineTo(rt.left + nWid * i, rt.bottom);
	}

	pDC->MoveTo(rt.left + 6 * nWid, rt.top + m_nWordH * 2);
	pDC->LineTo(rt.left + (6 + (int)vWeiyi.size()) * nWid, rt.top + m_nWordH * 2);
	
	rt = PageInfo.rtData;
	CSize szFont;
	//加载级
	strVal = L"加载级";
	szFont = pDC->GetTextExtent(strVal);
	rt.right = rt.left + nWid;
	rt.bottom = rt.top + m_nWordH * 4;
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + rt.Height() / 2 - szFont.cy, strVal);
	if (0 == HZProInfo.chUnit)
	{
		strVal = L"（kN）";
	}
	else
	{
		strVal = L"（kPa）";
	}
	szFont = pDC->GetTextExtent(strVal);
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + rt.Height() / 2, strVal);
	//实测荷载
	strVal = L"实测";
	szFont = pDC->GetTextExtent(strVal);
	rt.left += nWid;
	rt.right = rt.left + nWid;
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy / 2 - FONT_GAP, strVal);
	strVal = L"荷载";
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy * 3 / 2, strVal);
	if (0 == HZProInfo.chUnit)
	{
		strVal = L"（kN）";
	}
	else
	{
		strVal = L"（kPa）";
	}
	szFont = pDC->GetTextExtent(strVal);
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + +szFont.cy * 5 / 2 + FONT_GAP, strVal);
	//实测油压
	strVal = L"实测";
	szFont = pDC->GetTextExtent(strVal);
	rt.left += nWid;
	rt.right = rt.left + nWid;
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy / 2 - FONT_GAP, strVal);
	strVal = L"油压";
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy * 3 / 2, strVal);
	strVal = L"（MPa）";
	szFont = pDC->GetTextExtent(strVal);
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + +szFont.cy * 5 / 2 + FONT_GAP, strVal);
	//记录时间
	strVal = L"记录";
	szFont = pDC->GetTextExtent(strVal);
	rt.left += nWid;
	rt.right = rt.left + nWid;
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy / 2 - FONT_GAP, strVal);
	strVal = L"时间";
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy * 3 / 2, strVal);
	strVal = L"(hh:mm)";
	szFont = pDC->GetTextExtent(strVal);
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + +szFont.cy * 5 / 2 + FONT_GAP, strVal);
	//实际间隔
	strVal = L"实际";
	szFont = pDC->GetTextExtent(strVal);
	rt.left += nWid;
	rt.right = rt.left + nWid;
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy / 2 - FONT_GAP, strVal);
	strVal = L"间隔";
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy * 3 / 2, strVal);
	strVal = L"（min）";
	szFont = pDC->GetTextExtent(strVal);
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + +szFont.cy * 5 / 2 + FONT_GAP, strVal);
	//实际间隔
	strVal = L"平均";
	szFont = pDC->GetTextExtent(strVal);
	rt.left += nWid;
	rt.right = rt.left + nWid;
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy / 2 - FONT_GAP, strVal);
	strVal = L"位移";
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + szFont.cy * 3 / 2, strVal);
	strVal = L"（mm）";
	szFont = pDC->GetTextExtent(strVal);
	pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + +szFont.cy * 5 / 2 + FONT_GAP, strVal);
	//位移
	rt.top += m_nWordH * 2;
	for (int i = 0; i < (int)vWeiyi.size(); ++i)
	{
		rt.left += nWid;
		rt.right = rt.left + nWid;
		strVal.Format(L"位移%d", vWeiyi[i] + 1);
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	}
	rt.top  = PageInfo.rtData.top;
	rt.left += nWid;
	rt.right = PageInfo.rtData.right;
	if (g_DataType == DATA_2 || g_DataType == DATA_3)
	{
		strVal = L"上桩上拔";
		szFont = pDC->GetTextExtent(strVal);
		pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + rt.Height() / 2 - szFont.cy, strVal);
		strVal = L"（mm）";
		szFont = pDC->GetTextExtent(strVal);
		pDC->TextOutW(rt.left + rt.Width() / 2 - szFont.cx / 2, rt.top + rt.Height() / 2, strVal);
	}
	else
	{
		pDC->DrawText(L"备注", rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	}

	//位移读数
	rt.left = PageInfo.rtData.left + 6 * nWid;
	rt.right = rt.left + (int)vWeiyi.size() * nWid;
	rt.bottom = rt.top + m_nWordH * 2;
	pDC->DrawText(L"位移读数(mm)", rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

	vector<LOADVAL> vLoad;
	COleDateTime   tm;
	int nNoCnt = 0;
	LOADVAL stLoad;
	rt = PageInfo.rtData;
	rt.top += m_nWordH * 2;
	rt.bottom = rt.top + m_nWordH * 2;
	int nNo = 0;
	int nId = 0;
	float fLoadVal = 0.0f;
	int nDataType = LOAD_VALUE;
	for (int i = PageInfo.nBeginNo; i <= PageInfo.nEndNo; ++i, ++nNo)
	{
		if (g_DataType == DATA_2)
		{
			//记录荷载个数
			if (i == PageInfo.nBeginNo)
			{
				stLoad.fLoadVal = vDataInfo[i].fLoadValue;
				nNoCnt = 1;
				nId = vDataInfo[i].nIdx;
				stLoad.nCnt = nNoCnt;
				nDataType = vDataInfo[i].nJiaZaiOrXieZai;
				fLoadVal = stLoad.fLoadVal;
			}
			else
			{
				if (stLoad.fLoadVal == vDataInfo[i].fLoadValue)
				{
					nNoCnt++;
					stLoad.nCnt = nNoCnt;
				}
				else
				{
					vLoad.push_back(stLoad);
					stLoad.fLoadVal = vDataInfo[i].fLoadValue;
					nNoCnt = 1;
					nId = vDataInfo[i].nIdx;
					stLoad.nCnt = nNoCnt;
					nDataType = vDataInfo[i].nJiaZaiOrXieZai;
					fLoadVal = stLoad.fLoadVal;
				}
			}
		}
		else
		{
			//记录荷载个数
			if (i == PageInfo.nBeginNo)
			{
				stLoad.fLoadVal = vDataInfo[i].fLoadValue;
				nNoCnt = 1;
				nId = vDataInfo[i].nIdx;
				stLoad.nCnt = nNoCnt;
				nDataType = vDataInfo[i].nJiaZaiOrXieZai;
			}
			else
			{
				if (nDataType == vDataInfo[i].nJiaZaiOrXieZai && nId == vDataInfo[i].nIdx)
				{
					nNoCnt++;
					stLoad.nCnt = nNoCnt;
				}
				else
				{
					vLoad.push_back(stLoad);
					stLoad.fLoadVal = vDataInfo[i].fLoadValue;
					nNoCnt = 1;
					nId = vDataInfo[i].nIdx;
					stLoad.nCnt = nNoCnt;
					nDataType = vDataInfo[i].nJiaZaiOrXieZai;
				}
			}
		}
		
		rt.left = PageInfo.rtData.left + nWid;
		rt.right = rt.left + nWid;
		rt.top += m_nWordH * 2;
		rt.bottom = rt.top + m_nWordH * 2;
		//实测荷载
		strVal.Format(L"%.1f", vDataInfo[i].fCurLoad);
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		//实测油压
		rt.left += nWid;
		rt.right = rt.left + nWid;
		strVal.Format(L"%.1f", vDataInfo[i].fCurYouya);
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		//记录时间
		rt.left += nWid;
		rt.right = rt.left + nWid;
		strVal = vDataInfo[i].chRecordTime;
		tm.ParseDateTime(strVal);
		strVal.Format(L"%02d:%02d", tm.GetHour(), tm.GetMinute());
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		//实际间隔
		rt.left += nWid;
		rt.right = rt.left + nWid;
		strVal.Format(L"%d", vDataInfo[i].nTimeGap);
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		//平均位移
		rt.left += nWid;
		rt.right = rt.left + nWid;
		strVal.Format(L"%.02f", vDataInfo[i].fWeiyiAvg);
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		for (int w = 0; w < (int)vWeiyi.size(); ++w)
		{
			rt.left += nWid;
			rt.right = rt.left + nWid;
			strVal.Format(L"%.02f", vDataInfo[i].fWeiyi[vWeiyi[w]]);;
			pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		}
		//备注
		rt.left += nWid;
		rt.right = rt.left + nWid;
		if (g_DataType == DATA_2 || g_DataType == DATA_3)
		{
			strVal.Format(L"%.02f", vDataInfo[i].fShangZhuangShangBa);
		}
		else
		{
			strVal = vDataInfo[i].chBeiZhu;
		}		
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	}
	vLoad.push_back(stLoad);
	int nSumCnt = 0;
	rt = PageInfo.rtData;
	rt.right = rt.left + nWid;
	for (int i = 0; i < (int)vLoad.size(); ++i)
	{
		rt.top = PageInfo.rtData.top + m_nWordH * 4 + nSumCnt * m_nWordH * 2;
		rt.bottom = rt.top + vLoad[i].nCnt * m_nWordH * 2;
		nSumCnt += vLoad[i].nCnt;
		pDC->MoveTo(rt.left, rt.top);
		pDC->LineTo(rt.right, rt.top);
		strVal.Format(L"%.1f", vLoad[i].fLoadVal);
		pDC->DrawText(strVal, rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	}
	ClearVector(vDataInfo);
	ClearVector(vLoad);
	ClearVector(vWeiyi);
}

//画加载详测表
void CDrawCurve::DrawLoadOffTable(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"卸载详测表", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	if (PageInfo.bFirstPage && PageInfo.rtTableHead.Height() >= m_nWordH)
	{
		DrawHead(pDC, m_PrintSet.LoadHeadDef, PageInfo.rtTableHead);
	}
	if (PageInfo.rtData.Height() >= m_nWordH)
	{
		vector<PRINT_LOAD_INFO> vLoadInfo;
		if (GetLoadData(vLoadInfo, FALSE))
		{
			DrawLoadData(pDC, PageInfo, vLoadInfo);
		}
		vLoadInfo.clear();
// 		if (g_DataType == DATA_3)
// 		{
// 			DrawZphLoadData(pDC, PageInfo, m_vLoadOffInfo);
// 		}
// 		else if (g_DataType == DATA_0)
// 		{
// 			DrawLoadData(pDC, PageInfo, m_vLoadOffInfo);
// 		}
	}
	if (m_PrintSet.chSignInLoadoff)
	{
		DrawSign(pDC, PageInfo);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画加载详测表
void CDrawCurve::DrawLoadTable(CDC *pDC, PAGE_INFO PageInfo)
{
// 	if (g_DataType == DATA_0 || g_DataType == DATA_2 || g_DataType == DATA_3)
// 	{
// 		DrawTitle(pDC, L"加载详测表", PageInfo.rtTitle);
// 	}
// 	else
// 	{
// 		DrawTitle(pDC, L"测试详测表", PageInfo.rtTitle);
// 	}
	//绘制标题
	DrawTitle(pDC, g_strTableTitle[1],  PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	if (PageInfo.bFirstPage && PageInfo.rtTableHead.Height() >= m_nWordH)
	{
		DrawHead(pDC, m_PrintSet.LoadHeadDef, PageInfo.rtTableHead);
	}
	if (PageInfo.rtData.Height() >= m_nWordH)
	{
		vector<PRINT_LOAD_INFO> vLoadInfo;
		if (GetLoadData(vLoadInfo, TRUE))
		{
			DrawLoadData(pDC, PageInfo, vLoadInfo);
		}
		vLoadInfo.clear();
// 		if (g_DataType == DATA_0)
// 		{
// 			DrawLoadData(pDC, PageInfo, m_vLoadInfo);
// 		}
// 		else if (g_DataType == DATA_1)
// 		{
// 			DrawMgXQBData(pDC, PageInfo);
// 		}	
// 		else if (g_DataType == DATA_2)
// 		{
// 			DrawSpLoadData(pDC, PageInfo, m_vSpLoadInfo);
// 		}
// 		else if (g_DataType == DATA_3)
// 		{
// 			DrawZphLoadData(pDC, PageInfo, m_vLoadInfo);
// 		}
	}
	if (m_PrintSet.chSignInLoad)
	{
		DrawSign(pDC, PageInfo);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}


//画自平衡的等效数据表
void CDrawCurve::DrawSphQQsTable(CDC *pDC, PAGE_INFO PageInfo)
{
	DrawTitle(pDC, L"等效数据汇总表", PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	if (PageInfo.bFirstPage && PageInfo.rtTableHead.Height() >= m_nWordH)
	{
		DrawHead(pDC, m_PrintSet.LoadHeadDef, PageInfo.rtTableHead);
	}
	if (PageInfo.rtData.Height() >= m_nWordH)
	{
		DrawSphQQsData(pDC, PageInfo);
	}
	if (m_PrintSet.chSignInSum)
	{
		DrawSign(pDC, PageInfo);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//画汇总表
void CDrawCurve::DrawSumTable(CDC *pDC, PAGE_INFO PageInfo)
{	
	//绘制标题
	DrawTitle(pDC, g_strTableTitle[0], PageInfo.rtTitle);

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);

	if (PageInfo.bFirstPage && PageInfo.rtTableHead.Height() >= m_nWordH)
	{
		DrawHead(pDC, m_PrintSet.LoadHeadDef, PageInfo.rtTableHead);
	}
	if (PageInfo.rtData.Height() >= m_nWordH)
	{	
		DrawSummaryData(pDC, PageInfo);
	}
	if (m_PrintSet.chSignInSum)
	{
		DrawSign(pDC, PageInfo);
	}
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//写签名
void CDrawCurve::DrawSign(CDC *pDC, PAGE_INFO PageInfo)
{
	CString strVal(L"");
	CRect rt = PageInfo.rtData;
	rt.top = PageInfo.rtData.bottom;
	rt.bottom = rt.top + m_nWordH * 2;
	rt.left += 50;
	strVal = CHZData::GetInstance()->m_HZProInfo.chTestPeople;
	if (strVal != L"")
	{
		strVal = L"试验：" + strVal;
	}
	else
	{
		strVal = L"试验：";
	}
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	rt.left += PageInfo.rtData.Width() / 2;
	strVal = CHZData::GetInstance()->m_HZProInfo.chShenhePeople;
	if (strVal != L"")
	{
		strVal = L"校核：" + strVal;
	}
	else
	{
		strVal = L"校核：";
	}
	pDC->DrawText(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
}


//写标题
void CDrawCurve::DrawTitle(CDC *pDC, CString strTitle, CRect rtTitle)
{
	CString strVal(L"");
	strVal = m_PrintSet.chTitle;
	if (strVal == L"")
	{
		strVal = strTitle;
	}
	else
	{
		strVal += strTitle;
	}
	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CSize szFont;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont + FONT_TITLE, m_nY, 72), 0, 0, 0, FW_BOLD, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);
	pDC->DrawText(strVal, rtTitle, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

//获取每个头区域
CRect CDrawCurve::GetHeadRect(int nCnt, CRect &rtHead, BOOL bTable)
{
	CRect rt = rtHead;
	if (bTable)
	{
		rt.bottom = rt.top + m_nWordH;
	}
	else
	{
		rt.bottom = rt.top + m_nWordH * 2;
	}
	
	if (nCnt % 2 == 1)
	{
		rt.right = rtHead.left + rtHead.Width() / 2;
	}
	else
	{
		rt.left = rtHead.left + rtHead.Width() / 2;
		if (bTable)
		{
			rtHead.top += long(m_nWordH * 1.5);
		}
		else
		{
			rtHead.top += m_nWordH *2;
		}
	}
	rt.left += FONT_LEFT;
	return rt;
}

//写文字
void CDrawCurve::DrawTestW(CDC *pDC, CString strVal, CRect rt, BOOL bTable)
{
	if (bTable)
	{
		pDC->TextOutW(rt.left, rt.top, strVal);
	}
	else
	{
		pDC->DrawTextW(strVal, rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	}
}

//画表头
void CDrawCurve::DrawHead(CDC *pDC, Print_Def_Head HeadDef, CRect rtHead, BOOL bTable)
{
	HZ_PROJECT_INFO	HZProInfo = CHZData::GetInstance()->m_HZProInfo;
	CString strVal(L"");
	CString strText(L"");
	CRect rt;
	rt = rtHead;
	rt.left += FONT_LEFT;
	if (bTable)
	{
		rt.top += long(m_nWordH * 0.5);
		rt.bottom = long(rt.top + m_nWordH);
	}
	else
	{
		rt.bottom = rt.top + m_nWordH * 2;
	}

	if (HeadDef.bProject)
	{
		strVal = L"工程名称：";
		strText = HZProInfo.chProjectName;
		strVal += strText;
		DrawTestW(pDC, strVal, rt, bTable);

		rtHead.top += m_nWordH * 2;
	}
	
	int nCnt = 0;
	if (HeadDef.bPileNum)
	{
		nCnt++;
		strVal = L"桩编号：";
		strText = HZProInfo.chPileNum;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bPileLen)
	{
		nCnt++;
		strVal = L"桩长（m）：";
		strText.Format(L"%.01f", HZProInfo.fPilelength);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bPileJing)
	{
		nCnt++;
		strVal = L"桩径（mm）：";
		if (1 == HZProInfo.chShape)
		{
			strText.Format(L"%d x %d", HZProInfo.nPileDiam, HZProInfo.nPileDiamW);
		}
		else
		{
			strText.Format(L"%d", HZProInfo.nPileDiam);
		}
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bMaxLoad)
	{
		nCnt++;
		if (HZProInfo.chMaxLoadType == 1)
		{
			strVal = L"最大荷载(kPa)：";
		}
		else if (HZProInfo.chMaxLoadType == 1)
		{
			strVal = L"设计拉力(kN)：";
		}
		else
		{
			strVal = L"最大荷载(kN)：";
		}

// 		if (g_DataType == DATA_1)
// 		{
// 			strVal = L"设计拉力(kN)：";
// 		}
// 		else if (g_DataType == DATA_2)
// 		{
// 			strVal = L"最大荷载(kN)：";
// 		}
// 		else
// 		{
// 			strVal = L"最大荷载";
// 			if (0 == HZProInfo.chUnit)
// 			{
// 				strVal += L"(kN)：";
// 			}
// 			else
// 			{
// 				strVal += L"(kPa)：";
// 			}
// 		}
		
		strText.Format(L"%.1f", HZProInfo.nMaxLoad);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bLoadGrage)
	{
		nCnt++;

		if (g_DataType == DATA_0)
		{
			strVal = L"加载分级数：";
			strText.Format(L"%d", HZProInfo.nYuLoadGrade);
		}
		else if (g_DataType == DATA_1)
		{
			strVal = L"初始荷载(%)：";
			strText.Format(L"%d", HZProInfo.nChuShiHeZai);
		}
		else if (g_DataType == DATA_2)
		{
			strVal = L"加载分级数：";
			strText.Format(L"%d", HZProInfo.nYuLoadGrade);
		}
		else
		{
			strVal = L"加载分级数：";
			strText.Format(L"%d", HZProInfo.nYuLoadGrade);
		}

		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bXunHuanCnt)
	{
		nCnt++;
		strVal = L"循环次数：";
		strText.Format(L"%d", HZProInfo.chXunHuanCnt);

		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bTestUnit)
	{
		nCnt++;
		strVal = L"检测单位：";
		strText = HZProInfo.chTestUnit;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bTestDate)
	{
		nCnt++;
		strVal = L"检测日期：";
		strText = HZProInfo.chTestDate;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bStandard)
	{
		nCnt++;
		strVal = L"规范：";
		strText = L"";
		GetStandart(HZProInfo.chStandardType, HZProInfo.chStandard, strText);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bYiqiNum)
	{
		nCnt++;
		strVal = L"仪器编号：";
		strText = HZProInfo.chYiqiNum;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bPileType)
	{
		nCnt++;
		strVal = L"桩截面形状：";
		strText = g_strPileShape[HZProInfo.chShape];
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bTestType)
	{
		nCnt++;
		strVal = L"试验类型：";
		strText = g_strTestType[HZProInfo.chTestType];
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bJackNum)
	{
		nCnt++;
		strVal = L"千斤顶编号：";
		strText = HZProInfo.chJackNum;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bJackType)
	{
		nCnt++;
		strVal = L"千斤顶类型：";
		strText = g_strJackType[HZProInfo.chJackType];
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bJackCnt)
	{
		nCnt++;
		strVal = L"千斤顶个数：";
		strText.Format(L"%d", HZProInfo.nJackCnts);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bWeiyiNum)
	{
		nCnt++;
		strVal = L"位移传感器编号：";
		strText = HZProInfo.chWeiYiSensorNum;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bWeiyiType)
	{
		nCnt++;
		strVal = L"位移传感器型号：";
		strText = HZProInfo.chWeiYiSensorType;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bYaliNum)
	{
		nCnt++;
		strVal = L"压力传感器编号：";
		strText = HZProInfo.chYaLiSensorNum;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bYaliType)
	{
		nCnt++;
		strVal = L"压力传感器型号：";
		strText = HZProInfo.chYaLiSensorType;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bPlateType)
	{
		nCnt++;
		strVal = L"承压板形状：";
		strText = g_strPlateType[HZProInfo.chPlateType];
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bPlateArea)
	{
		nCnt++;
		strVal = L"承压板面积(m²)：";
		strText.Format(L"%.01f", HZProInfo.fPlateArea);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bLoadTime)
	{
		nCnt++;
		strVal = L"加荷时间：";
		strText.Format(L"%d", HZProInfo.nLoadTime);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bLoadoffTime)
	{
		nCnt++;
		strVal = L"卸荷时间：";
		strText.Format(L"%d", HZProInfo.nLoadoffTime);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bTableGap)
	{
		nCnt++;
		strVal = L"上下表距：";
		strText.Format(L"%d", HZProInfo.nTableGap);
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}
	if (HeadDef.bBeizhu)
	{
		nCnt++;
		strVal = L"备注：";
		strText = HZProInfo.chBeizhu;
		strVal += strText;
		rt = GetHeadRect(nCnt, rtHead, bTable);
		DrawTestW(pDC, strVal, rt, bTable);
	}

}

//画页眉页脚和页码
void CDrawCurve::PrintPageNum(CDC *pDC, int nCurrPage, CRect rt)
{
	CString strVal(L"");
	CSize szFont;
	int nPosX = 0;
	int nPosY = 0;
	int nCurPage = 0;	//当前页码
	nCurPage = nCurrPage + m_PrintSet.nPageBegin - 1;
	if (0 == m_PrintSet.chPageStyle)
	{
		strVal = L"";
	}
	else if (1 == m_PrintSet.chPageStyle)
	{
		strVal.Format(L"%d", nCurPage);
	}
	else if (2 == m_PrintSet.chPageStyle)
	{
		strVal.Format(L"-%d-", nCurPage);
	}
	else if (3 == m_PrintSet.chPageStyle)
	{
		strVal.Format(L"第%d页", nCurPage);
	}
	else if (4 == m_PrintSet.chPageStyle)
	{
		if (m_PrintSet.nPageTotal <= 0)
		{
			strVal.Format(L"第%d页 共%d页", nCurPage, g_nPageCnt + m_PrintSet.nPageBegin - 1);
		}
		else
		{
			strVal.Format(L"第%d页 共%d页", nCurPage, m_PrintSet.nPageTotal);
		}
	}
	else{}

	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(10, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);
	szFont = pDC->GetOutputTextExtent(strVal);

	nPosY = rt.bottom + szFont.cy / 2;
	if (0 == m_PrintSet.chPagePos)  //居左
	{
		nPosX = rt.left;
	}
	else if (1 == m_PrintSet.chPagePos)   //居中
	{
		nPosX = rt.left + rt.Width() / 2 - szFont.cx / 2;
	}
	else   //居右
	{
		nPosX = rt.right - szFont.cx;
	}
	pDC->TextOutW(nPosX, nPosY, strVal);

	//页脚
	if (m_PrintSet.chPageFoot)
	{
		nPosY = rt.bottom + szFont.cy + szFont.cy / 2;
		strVal = m_PrintSet.chPageFootStr;
		szFont = pDC->GetOutputTextExtent(strVal);
		nPosY += szFont.cy / 2;
		nPosX = rt.left;
		pDC->TextOutW(nPosX, nPosY, strVal);
	}
	//页眉
	if (m_PrintSet.chPageHead)
	{
		strVal = m_PrintSet.chPageHeadStr;
		szFont = pDC->GetOutputTextExtent(strVal);
		nPosY = rt.top - szFont.cy / 2 - szFont.cy;
		nPosX = rt.left;
		pDC->TextOutW(nPosX, nPosY, strVal);
	}
	
	pDC->SelectObject(fontOld);
	font.DeleteObject();
}

int CDrawCurve::LenToPrintview(int nLen)
{
	return (nLen * m_nX * 10 / 254);	
}


void CDrawCurve::CleaarVector()
{
	ClearVector(m_vPageInfo);
	ClearVector(m_vLoadInfo);
	ClearVector(m_vLoadOffInfo);
	ClearVector(m_vSpLoadInfo);
}

//初始化数据
void CDrawCurve::InitData(CDC *pDC)
{
	//  毫米转化成像素公式*nx/25.4 
	int nWidth = pDC->GetDeviceCaps(HORZRES);			//像素毫米
	int nHight = pDC->GetDeviceCaps(VERTRES);
	m_nX = pDC->GetDeviceCaps(LOGPIXELSX);			//用于毫米转化成像素
	m_nY = pDC->GetDeviceCaps(LOGPIXELSY);
	int nLeft = int(m_PrintSet.nLeft) * m_nX * 10 / 254;
	int nUp = int(m_PrintSet.nUp)  * m_nY * 10 / 254;
	int nRight = int(m_PrintSet.nRight)  * m_nX * 10 / 254;
	int nDown = int(m_PrintSet.nDown)  * m_nY * 10 / 254;

	m_rtPrint.left = nLeft;
	m_rtPrint.right = nWidth - nRight;
	m_rtPrint.top = nUp;
	m_rtPrint.bottom = nHight - nDown;

	CString strVal(L"测试数据的(mm)");
	//字体字号
	CString strFont(L"");
	strFont = m_PrintSet.chFont;
	int nFont = m_PrintSet.chFontSize;
	CSize szFont;
	CFont	font, *fontOld = NULL;
	font.CreateFont(MulDiv(nFont, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);
	szFont = pDC->GetOutputTextExtent(strVal);
	//字体高度
	m_nWordH = szFont.cy;
	m_nWordW = szFont.cx;
	pDC->SelectObject(fontOld);
	font.DeleteObject();

	font.CreateFont(MulDiv(nFont + FONT_TITLE, m_nY, 72), 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, strFont);
	fontOld = pDC->SelectObject(&font);
	szFont = pDC->GetOutputTextExtent(strVal);
	//字体高度
	m_nTitleH = szFont.cy;
	pDC->SelectObject(fontOld);
	font.DeleteObject();

	//情况信息
	CleaarVector();

	//获取加载信息
	GetLoadInfo();

	int nSize = 0;
	PRINT_TYPE PrintType = eSUM_TABLE;
	//获取汇总表页码数量
	if (m_PrintSet.chPrintSumTable)
	{
		if (GetSummaryInfo(nSize, PrintType))
		{
			GetTablePages(nSize, PrintType, m_vPageInfo);
		}
	}
	//获取加载表页码数量
	if (m_PrintSet.chPrintLoadTable)
	{
		if (GetLoadTableInfo(nSize, PrintType))
		{
			GetTablePages(nSize, PrintType, m_vPageInfo);
		}
	}
	//获取卸载表页码数量
	if (m_PrintSet.chPrintLoadOffTable)
	{
		if (GetLoadoffTableInfo(nSize, PrintType))
		{
			GetTablePages(nSize, PrintType, m_vPageInfo);
		}
	}

	//自平衡试验的等效数据
	if (m_PrintSet.chPrintQQSTable)
	{
		if (GetQQsTableInfo(nSize, PrintType))
		{
			GetTablePages(nSize, PrintType, m_vPageInfo);
		}
	}

	//原始记录表
	if (m_PrintSet.chPrintOriginalTable)
	{
		GetTablePages((int)CHZData::GetInstance()->GetDataInfo().size(), eORIGINAL_TABLE, m_vPageInfo);
	}

	//配置信息表
	if (m_PrintSet.chPrintConfigTable)
	{
		PAGE_INFO Page_Info;
		ZeroMemory(&Page_Info, sizeof(PAGE_INFO));
		//标题区域
		Page_Info.rtTitle = m_rtPrint;
		Page_Info.rtTitle.bottom = Page_Info.rtTitle.top + m_nTitleH * 2;
		Page_Info.rtData = m_rtPrint;
		Page_Info.rtData.top = Page_Info.rtTitle.bottom;
		Page_Info.Print_Type = eCONFIT_TABLE;
		if (m_PrintSet.chSignInConfig)
		{
			Page_Info.rtData.bottom -= m_nWordH * 2;
		}
		m_vPageInfo.push_back(Page_Info);
	}
	//获取曲线页码
	GetCurvePages(m_vPageInfo);
	g_nPageCnt = (int)m_vPageInfo.size();
}

//获取表格页码
void CDrawCurve::GetTablePages(int nDataCnt, PRINT_TYPE Print_Type, vector<PAGE_INFO> &vPageInfo)
{
	if (0 == nDataCnt)
	{
		return;
	}
	PAGE_INFO Page_Info;
	ZeroMemory(&Page_Info, sizeof(PAGE_INFO));
	Page_Info.Print_Type = Print_Type;

	Page_Info.bFirstPage = TRUE;
	int nH = 0;
	//标题区域
	Page_Info.rtTitle = m_rtPrint;
	Page_Info.rtTitle.bottom = Page_Info.rtTitle.top + m_nTitleH * 2;
	//表头区域
	int nTitleH = 0;
	if (m_PrintSet.SumHeadDef.bProject && (Print_Type == eORIGINAL_TABLE || Print_Type == eMgXQB_TABLE))
	{
		nTitleH = int(m_nWordH * 1.5);
	}
	else if (m_PrintSet.LoadHeadDef.bProject && (Print_Type == eLOADOFF_TABLE ||
		Print_Type == eLOAD_TABLE || Print_Type == eSUM_TABLE || Print_Type == eZphQQs_Table))
	{
		nTitleH = int(m_nWordH * 1.5);
	}
	nH += nTitleH;
	//减去表格高度
	if (Print_Type == eORIGINAL_TABLE || Print_Type == eMgXQB_TABLE)
	{
		nH += GetRecordHeadHig();
	}
	else if (Print_Type == eLOADOFF_TABLE || Print_Type == eLOAD_TABLE || Print_Type == eSUM_TABLE || Print_Type == eZphQQs_Table)
	{
		nH += GetXiangCeHeadHig();
	}
	
	Page_Info.rtTableHead = m_rtPrint;
	Page_Info.rtTableHead.top = Page_Info.rtTitle.bottom;
	Page_Info.rtTableHead.bottom = Page_Info.rtTableHead.top + nH;
	//数据区域
	Page_Info.rtData = m_rtPrint;
	Page_Info.rtData.top = Page_Info.rtTableHead.bottom + TABLE_GAP;
	//减去试验/校核签名高度
	int nSignH = 0;
	if (m_PrintSet.chSignInSum && Print_Type == eSUM_TABLE)
	{
		nSignH = m_nWordH * 2;
	}
	else if (m_PrintSet.chSignInLoad && Print_Type == eLOAD_TABLE)
	{
		nSignH = m_nWordH * 2;
	}
	else if (m_PrintSet.chSignInLoadoff && Print_Type == eLOADOFF_TABLE)
	{
		nSignH = m_nWordH * 2;
	}
	else if (m_PrintSet.chSignInOriginal && (Print_Type == eORIGINAL_TABLE || Print_Type == eORIGINAL_TABLE))
	{
		nSignH = m_nWordH * 2;
	}
	else if (m_PrintSet.chSignInQQS && Print_Type == eZphQQs_Table)
	{
		nSignH = m_nWordH * 2;
	}

	Page_Info.rtData.bottom -= nSignH;

	//数据区表格头2行
	Page_Info.nBeginNo = 0;
	int nLastNo = (Page_Info.rtData.Height() / (m_nWordH * 2));
	nLastNo -= 2;
	if (nLastNo > nDataCnt)
	{
		Page_Info.nEndNo = nDataCnt - 1;
	}
	else
	{
		Page_Info.nEndNo = nLastNo - 1;
	}

	vPageInfo.push_back(Page_Info);
	if (nLastNo < nDataCnt)
	{
		Page_Info.bFirstPage = FALSE;
		Page_Info.rtData = m_rtPrint;
		Page_Info.rtData.top = Page_Info.rtTitle.bottom;
		//减去试验/校核签名高度
		Page_Info.rtData.bottom -= nSignH;

		int nOnePageCnt = (Page_Info.rtData.Height() / (m_nWordH * 2));
		nOnePageCnt -= 2;
		int nPageCnt = (nDataCnt - nLastNo + nOnePageCnt - 1) / nOnePageCnt;
		for (int i = 0; i < nPageCnt; ++i)
		{
			Page_Info.nBeginNo = nLastNo + i * nOnePageCnt;
			if (i == nPageCnt - 1)
			{
				Page_Info.nEndNo = nDataCnt - 1;
			}
			else
			{
				Page_Info.nEndNo = nLastNo + (i + 1) * nOnePageCnt - 1;
			}
			vPageInfo.push_back(Page_Info);
		}
	}
}

//获取曲线页码数量
void CDrawCurve::GetCurvePages(vector<PAGE_INFO> &vPageInfo)
{
	PAGE_INFO Page_Info;
	ZeroMemory(&Page_Info, sizeof(PAGE_INFO));
	//标题区域
	Page_Info.rtTitle = m_rtPrint;
	Page_Info.rtTitle.bottom = Page_Info.rtTitle.top + m_nTitleH * 2;
	//表格高度
	int nH = GetCurveHeadHig();
	Page_Info.rtTableHead = m_rtPrint;
	Page_Info.rtTableHead.top = Page_Info.rtTitle.bottom;
	Page_Info.rtTableHead.bottom = Page_Info.rtTableHead.top + nH;
	if (m_PrintSet.CurveHeadDef.bProject)
	{
		Page_Info.rtTableHead.bottom += m_nWordH * 2;
	}
	//画图区域
	Page_Info.rtData = m_rtPrint;
	Page_Info.rtData.top = Page_Info.rtTableHead.bottom;

	CRect rt = Page_Info.rtData;
	rt.top += 10;
	rt.bottom -= 10;
	rt.left += 10;
	rt.right -= 10;
	//获取曲线区域
	int nCuWid = 0;
	int nCuHid = 0;
	CRect rtCurve = rt;
	CRect rtCurve2 = rt;
	CRect rtCurve3 = rt;
	if (m_PrintSet.chCurvePrintStype == 0)
	{
		nCuHid = rt.Height();
		nCuWid = rt.Width();
		if (m_PrintSet.chScale == 0)
		{
			nCuWid = nCuHid * 2 / 3;
			if (nCuWid > rt.Width())
			{
				nCuWid = rt.Width();
				nCuHid = nCuWid * 3 / 2;
				if (nCuHid > rt.Height())
				{
					nCuHid = rt.Height();
				}
			}
		}
		else
		{
			nCuHid = nCuWid;
			if (nCuHid > rt.Height())
			{
				nCuHid = rt.Height();
				nCuWid = nCuHid;
				if (nCuWid > rt.Width())
				{
					nCuWid = rt.Width();
					nCuHid = nCuWid;
				}
			}
		}
		rtCurve.left = rt.left + rt.Width() / 2 - nCuWid / 2;
		rtCurve.top = rt.top + rt.Height() / 2 - nCuHid / 2;
		rtCurve.right = rtCurve.left + nCuWid;
		rtCurve.bottom = rtCurve.top + nCuHid;

		if (m_PrintSet.chQs)
		{
			Page_Info.Print_Type = eCURVE_QS;
			Page_Info.rtDraw[0] = rtCurve;
			vPageInfo.push_back(Page_Info);
		}
		if (m_PrintSet.chSlgQ)
		{
			Page_Info.Print_Type = eCURVE_SLGQ;
			Page_Info.rtDraw[0] = rtCurve;
			vPageInfo.push_back(Page_Info);
		}
		if (m_PrintSet.chSlgt)
		{
			Page_Info.Print_Type = eCURVE_SLGT;
			Page_Info.rtDraw[0] = rtCurve;
			vPageInfo.push_back(Page_Info);
		}
	}
	else if (m_PrintSet.chCurvePrintStype == 1 || m_PrintSet.chCurvePrintStype == 2)
	{
		if (!m_PrintSet.chPrintVorH)
		{
			nCuHid = rt.Height() / 2;
			nCuWid = rt.Width();
			if (m_PrintSet.chScale == 0)
			{
				nCuWid = nCuHid * 2 / 3;
				if (nCuWid > rt.Width())
				{
					nCuWid = rt.Width();
					nCuHid = nCuWid * 3 / 2;
					if (nCuHid > rt.Height() / 2)
					{
						nCuHid = rt.Height() / 2;
					}
				}
			}
			else
			{
				nCuHid = nCuWid;
				if (nCuHid > rt.Height() / 2)
				{
					nCuHid = rt.Height() / 2;
					nCuWid = nCuHid;
					if (nCuWid > rt.Width())
					{
						nCuWid = rt.Width();
					}
				}
			}
		}
		else
		{
			nCuHid = rt.Height();
			nCuWid = rt.Width() / 2;
			if (m_PrintSet.chScale == 0)
			{
				nCuWid = nCuHid * 2 / 3;
				if (nCuWid > rt.Width() / 2)
				{
					nCuWid = rt.Width() / 2;
					nCuHid = nCuWid * 3 / 2;
					if (nCuHid > rt.Height())
					{
						nCuHid = rt.Height();
					}
				}
			}
			else
			{
				nCuHid = nCuWid;
				if (nCuHid > rt.Height())
				{
					nCuHid = rt.Height();
					nCuWid = nCuHid;
					if (nCuWid > rt.Width())
					{
						nCuWid = rt.Width() / 2;
					}
				}
			}
		}

		if (!m_PrintSet.chPrintVorH)
		{
			rtCurve.left = rt.left + rt.Width() / 2 - nCuWid / 2;
			rtCurve.top = rt.top + rt.Height() / 2 - nCuHid;
			rtCurve.right = rtCurve.left + nCuWid;
			rtCurve.bottom = rtCurve.top + nCuHid;

			rtCurve2 = rtCurve;
			rtCurve2.top = rtCurve.bottom;
			rtCurve2.bottom = rtCurve2.top + nCuHid;
		}
		else
		{
			rtCurve.left = rt.left + rt.Width() / 4 - nCuWid / 2;
			rtCurve.top = rt.top + rt.Height() / 2 - nCuHid / 2;
			rtCurve.right = rtCurve.left + nCuWid;
			rtCurve.bottom = rtCurve.top + nCuHid;

			rtCurve2 = rtCurve;
			rtCurve2.left = rt.left + rt.Width() * 3 / 4 - nCuWid / 2;
			rtCurve2.right = rtCurve2.left + nCuWid;
		}

		if (m_PrintSet.chCurvePrintStype == 1)
		{
			Page_Info.Print_Type = eCURVE_QS_SLGT;
			Page_Info.rtDraw[0] = rtCurve;
			Page_Info.rtDraw[1] = rtCurve2;
			vPageInfo.push_back(Page_Info);
			if (m_PrintSet.chSlgQ)
			{
				nCuHid = rt.Height();
				nCuWid = rt.Width();
				if (m_PrintSet.chScale == 0)
				{
					nCuWid = nCuHid * 2 / 3;
					if (nCuWid > rt.Width())
					{
						nCuWid = rt.Width();
						nCuHid = nCuWid * 3 / 2;
						if (nCuHid > rt.Height())
						{
							nCuHid = rt.Height();
						}
					}
				}
				else
				{
					nCuHid = nCuWid;
					if (nCuHid > rt.Height())
					{
						nCuHid = rt.Height();
						nCuWid = nCuHid;
						if (nCuWid > rt.Width())
						{
							nCuWid = rt.Width();
							nCuHid = nCuWid;
						}
					}
				}
				rtCurve.left = rt.left + rt.Width() / 2 - nCuWid / 2;
				rtCurve.top = rt.top + rt.Height() / 2 - nCuHid / 2;
				rtCurve.right = rtCurve.left + nCuWid;
				rtCurve.bottom = rtCurve.top + nCuHid;

				if (g_DataType == DATA_0)
				{
					Page_Info.Print_Type = eCURVE_SLGQ;
					Page_Info.rtDraw[0] = rtCurve;
					vPageInfo.push_back(Page_Info);
				}				
			}
		}
		else if (m_PrintSet.chCurvePrintStype == 2)
		{
			if (m_PrintSet.chQs)
			{
				nCuHid = rt.Height();
				nCuWid = rt.Width();
				if (m_PrintSet.chScale == 0)
				{
					nCuWid = nCuHid * 2 / 3;
					if (nCuWid > rt.Width())
					{
						nCuWid = rt.Width();
						nCuHid = nCuWid * 3 / 2;
						if (nCuHid > rt.Height())
						{
							nCuHid = rt.Height();
						}
					}
				}
				else
				{
					nCuHid = nCuWid;
					if (nCuHid > rt.Height())
					{
						nCuHid = rt.Height();
						nCuWid = nCuHid;
						if (nCuWid > rt.Width())
						{
							nCuWid = rt.Width();
							nCuHid = nCuWid;
						}
					}
				}
				rtCurve3.left = rt.left + rt.Width() / 2 - nCuWid / 2;
				rtCurve3.top = rt.top + rt.Height() / 2 - nCuHid / 2;
				rtCurve3.right = rtCurve3.left + nCuWid;
				rtCurve3.bottom = rtCurve3.top + nCuHid;

				Page_Info.Print_Type = eCURVE_QS;
				Page_Info.rtDraw[0] = rtCurve3;
				vPageInfo.push_back(Page_Info);
			}

			Page_Info.Print_Type = eCURVE_SLGQ_SLGT;
			Page_Info.rtDraw[0] = rtCurve;
			Page_Info.rtDraw[1] = rtCurve2;
			vPageInfo.push_back(Page_Info);
		}
	}
	else if (m_PrintSet.chCurvePrintStype == 3)
	{
		if (!m_PrintSet.chPrintVorH)
		{
			nCuHid = rt.Height() / 2;
			nCuWid = rt.Width() / 2;
			if (m_PrintSet.chScale == 0)
			{
				nCuWid = nCuHid * 2 / 3;
				if (nCuWid > rt.Width() / 2)
				{
					nCuWid = rt.Width() / 2;
					nCuHid = nCuWid * 3 / 2;
					if (nCuHid > rt.Height() / 2)
					{
						nCuHid = rt.Height() / 2;
					}
				}
			}
			else
			{
				nCuHid = nCuWid;
				if (nCuHid > rt.Height() / 2)
				{
					nCuHid = rt.Height() / 2;
					nCuWid = nCuHid;
					if (nCuWid > rt.Width() / 2)
					{
						nCuWid = rt.Width() / 2;
					}
				}
			}
		}
		else
		{
			nCuHid = rt.Height();
			nCuWid = rt.Width() / 3;
			if (m_PrintSet.chScale == 0)
			{
				nCuWid = nCuHid * 2 / 3;
				if (nCuHid > rt.Width() / 3)
				{
					nCuWid = rt.Width() / 3;
					nCuHid = nCuWid * 3 / 2;
					if (nCuHid > rt.Height())
					{
						nCuHid = rt.Height();
					}
				}
			}
			else
			{
				nCuHid = nCuWid;
				if (nCuHid > rt.Height())
				{
					nCuHid = rt.Height();
					nCuWid = nCuHid;
					if (nCuWid > rt.Width() / 3)
					{
						nCuWid = rt.Width() / 3;
					}
				}
			}
		}

		if (!m_PrintSet.chPrintVorH)
		{
			rtCurve.left = rt.left + rt.Width() / 2 - nCuWid;
			rtCurve.top = rt.top + rt.Height() / 2 - nCuHid;
			rtCurve.right = rtCurve.left + nCuWid;
			rtCurve.bottom = rtCurve.top + nCuHid;

			rtCurve2 = rtCurve;
			rtCurve2.left = rtCurve.right;
			rtCurve2.right = rtCurve2.left + nCuWid;

			rtCurve3 = rtCurve;
			rtCurve3.top = rtCurve.bottom;
			rtCurve3.bottom = rtCurve3.top + nCuHid;
		}
		else
		{
			rtCurve.left = rt.left + rt.Width() / 3 - nCuWid;
			rtCurve.top = rt.top + rt.Height() / 2 - nCuHid / 2;
			rtCurve.right = rtCurve.left + nCuWid;
			rtCurve.bottom = rtCurve.top + nCuHid;

			rtCurve2 = rtCurve;
			rtCurve2.left = rtCurve.right;
			rtCurve2.right = rtCurve2.left + nCuWid;

			rtCurve3 = rtCurve2;
			rtCurve3.left = rtCurve2.right;
			rtCurve3.right = rtCurve3.left + nCuWid;
		}
		Page_Info.Print_Type = eCURVE_ALL;
		Page_Info.rtDraw[0] = rtCurve;
		Page_Info.rtDraw[1] = rtCurve2;
		Page_Info.rtDraw[2] = rtCurve3;
		vPageInfo.push_back(Page_Info);
	}
	//等效Qs
	if (m_PrintSet.chQQs && g_DataType == DATA_3)
	{
		nCuHid = rt.Height();
		nCuWid = rt.Width();
		if (m_PrintSet.chScale == 0)
		{
			nCuWid = nCuHid * 2 / 3;
			if (nCuWid > rt.Width())
			{
				nCuWid = rt.Width();
				nCuHid = nCuWid * 3 / 2;
				if (nCuHid > rt.Height())
				{
					nCuHid = rt.Height();
				}
			}
		}
		else
		{
			nCuHid = nCuWid;
			if (nCuHid > rt.Height())
			{
				nCuHid = rt.Height();
				nCuWid = nCuHid;
				if (nCuWid > rt.Width())
				{
					nCuWid = rt.Width();
					nCuHid = nCuWid;
				}
			}
		}
		rtCurve.left = rt.left + rt.Width() / 2 - nCuWid / 2;
		rtCurve.top = rt.top + rt.Height() / 2 - nCuHid / 2;
		rtCurve.right = rtCurve.left + nCuWid;
		rtCurve.bottom = rtCurve.top + nCuHid;

		Page_Info.Print_Type = eCurve_ZphQQs;
		Page_Info.rtDraw[0] = rtCurve;
		vPageInfo.push_back(Page_Info);
	}
}

//获取加载和卸载详细信息
void CDrawCurve::GetLoadInfo()
{
	m_vLoadInfo.clear();
	m_vLoadOffInfo.clear();
	PRINT_LOAD_INFO Load_Info;
	BOOL bLoadZero = FALSE; //是否加载了0 timeGap
	BOOL bLoadOffZero = FALSE;
	vector<DATA_INFO> vDataInfo = CHZData::GetInstance()->m_vDataInfo;
	HZ_PROJECT_INFO	HZProInfo = CHZData::GetInstance()->m_HZProInfo;
	int nBeijiId = 0;
	int nId = 0;	//用于统计本级
	int nTimeCnt = 0;
	float fLastWeiyi = 0;
	float fLastUpWeiyi = 0;
	for (int i = 0; i < (int)vDataInfo.size(); ++i)
	{
		if (vDataInfo[i].fLoadValue > EPSINON && vDataInfo[i].fLoadValue < -EPSINON)
		{
			continue;;
		}
		if (vDataInfo[i].nJiaZaiOrXieZai == LOAD_VALUE)
		{
			if (!bLoadZero)
			{
				nTimeCnt = 0;
				nBeijiId = vDataInfo[i].nIdx;
				//初始设置
				ZeroMemory(&Load_Info, sizeof(PRINT_LOAD_INFO));
				Load_Info.nBenJiId = nId;
				Load_Info.fLoadVal = vDataInfo[i].fLoadValue;
				Load_Info.nTimeGap = HZProInfo.nLoadTimeList[0];
				Load_Info.nSumTime = Load_Info.nTimeGap;	//累计时间
				Load_Info.fWeiyiAge = vDataInfo[i].fWeiyiAvg;
				Load_Info.fWeiyiGap = vDataInfo[i].fWeiyiAvg - fLastWeiyi;
				fLastWeiyi = vDataInfo[i].fWeiyiAvg;
				Load_Info.fUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
				Load_Info.fUpWeiyiGap = vDataInfo[i].fShangZhuangShangBa - fLastUpWeiyi;
				fLastUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
				for (int w = 0; w < 8; ++w)
				{
					Load_Info.fWeiyi[w] = vDataInfo[i].fWeiyi[w];
				}
				m_vLoadInfo.push_back(Load_Info);
				bLoadZero = TRUE;
			}
			else
			{
// 				if (vDataInfo[i].nTimeGap == 0)
// 				{
// 					continue;
// 				}
// 				else
				if (nBeijiId == vDataInfo[i].nIdx)
				{
					nTimeCnt++;
					if (nTimeCnt > 11)
					{
						nTimeCnt = 11;
					}
					Load_Info.nTimeGap = HZProInfo.nLoadTimeList[nTimeCnt];
					Load_Info.nSumTime += Load_Info.nTimeGap;	//累计时间
					Load_Info.fWeiyiAge = vDataInfo[i].fWeiyiAvg;
					Load_Info.fWeiyiGap = vDataInfo[i].fWeiyiAvg - fLastWeiyi;
					fLastWeiyi = vDataInfo[i].fWeiyiAvg;
					Load_Info.fUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					Load_Info.fUpWeiyiGap = vDataInfo[i].fShangZhuangShangBa - fLastUpWeiyi;
					fLastUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					for (int w = 0; w < 8; ++w)
					{
						Load_Info.fWeiyi[w] = vDataInfo[i].fWeiyi[w];
					}
					m_vLoadInfo.push_back(Load_Info);
				}
				else
				{
					nBeijiId = vDataInfo[i].nIdx;
					//初始设置
					nId++;
					nTimeCnt = 0;
					Load_Info.nBenJiId = nId;
					Load_Info.fLoadVal = vDataInfo[i].fLoadValue;
					Load_Info.nTimeGap = HZProInfo.nLoadTimeList[nTimeCnt];
					Load_Info.nSumTime += Load_Info.nTimeGap;	//累计时间
					Load_Info.fWeiyiAge = vDataInfo[i].fWeiyiAvg;
					Load_Info.fWeiyiGap = vDataInfo[i].fWeiyiAvg - fLastWeiyi;
					fLastWeiyi = vDataInfo[i].fWeiyiAvg;
					Load_Info.fUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					Load_Info.fUpWeiyiGap = vDataInfo[i].fShangZhuangShangBa - fLastUpWeiyi;
					fLastUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					for (int w = 0; w < 8; ++w)
					{
						Load_Info.fWeiyi[w] = vDataInfo[i].fWeiyi[w];
					}
					m_vLoadInfo.push_back(Load_Info);
				}
			}
		}
		else
		{
			if (!bLoadOffZero)
			{
				nBeijiId = vDataInfo[i].nIdx;
				//初始设置
				nId = 0;
				nTimeCnt = 0;
				Load_Info.nBenJiId = nId;
				Load_Info.fLoadVal = vDataInfo[i].fLoadValue;
				Load_Info.nTimeGap = HZProInfo.nLoadOffTimeList[nTimeCnt];
				Load_Info.nSumTime += Load_Info.nTimeGap;	//累计时间
				Load_Info.fWeiyiAge = vDataInfo[i].fWeiyiAvg;
				Load_Info.fWeiyiGap = vDataInfo[i].fWeiyiAvg - fLastWeiyi;
				fLastWeiyi = vDataInfo[i].fWeiyiAvg;
				Load_Info.fUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
				Load_Info.fUpWeiyiGap = vDataInfo[i].fShangZhuangShangBa - fLastUpWeiyi;
				fLastUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
				for (int w = 0; w < 8; ++w)
				{
					Load_Info.fWeiyi[w] = vDataInfo[i].fWeiyi[w];
				}
				m_vLoadOffInfo.push_back(Load_Info);
				bLoadOffZero = TRUE;
			}
			else
			{
// 				if (vDataInfo[i].nTimeGap == 0)
// 				{
// 					continue;
// 				}
// 				else 
				if (nBeijiId == vDataInfo[i].nIdx)
				{
					nTimeCnt++;
					if (nTimeCnt > 11)
					{
						nTimeCnt = 11;
					}
					Load_Info.nTimeGap = HZProInfo.nLoadOffTimeList[nTimeCnt];
					Load_Info.nSumTime += Load_Info.nTimeGap;	//累计时间
					Load_Info.fWeiyiAge = vDataInfo[i].fWeiyiAvg;
					Load_Info.fWeiyiGap = vDataInfo[i].fWeiyiAvg - fLastWeiyi;
					fLastWeiyi = vDataInfo[i].fWeiyiAvg;
					Load_Info.fUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					Load_Info.fUpWeiyiGap = vDataInfo[i].fShangZhuangShangBa - fLastUpWeiyi;
					fLastUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					for (int w = 0; w < 8; ++w)
					{
						Load_Info.fWeiyi[w] = vDataInfo[i].fWeiyi[w];
					}
					m_vLoadOffInfo.push_back(Load_Info);
				}
				else
				{
					nBeijiId = vDataInfo[i].nIdx;
					//初始设置
					nId++;
					nTimeCnt = 0;
					Load_Info.nBenJiId = nId;
					Load_Info.fLoadVal = vDataInfo[i].fLoadValue;
					Load_Info.nTimeGap = HZProInfo.nLoadOffTimeList[nTimeCnt];
					Load_Info.nSumTime += Load_Info.nTimeGap;	//累计时间
					Load_Info.fWeiyiAge = vDataInfo[i].fWeiyiAvg;
					Load_Info.fWeiyiGap = vDataInfo[i].fWeiyiAvg - fLastWeiyi;
					fLastWeiyi = vDataInfo[i].fWeiyiAvg;
					Load_Info.fUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					Load_Info.fUpWeiyiGap = vDataInfo[i].fShangZhuangShangBa - fLastUpWeiyi;
					fLastUpWeiyi = vDataInfo[i].fShangZhuangShangBa;
					for (int w = 0; w < 8; ++w)
					{
						Load_Info.fWeiyi[w] = vDataInfo[i].fWeiyi[w];
					}
					m_vLoadOffInfo.push_back(Load_Info);
				}
			}
		}
	}
}


//获取详测表头区域高度
int CDrawCurve::GetXiangCeHeadHig()
{
	int nHig = 0;
	int nCnt = GetDefCheckCnt(m_PrintSet.LoadHeadDef);
	nCnt = (nCnt + 1) / 2;
	if (nCnt)
	{
		int nH = int(m_nWordH * 1.5);
		nHig = (nH * nCnt + m_nWordH / 2);
	}
	return nHig;
}

//获取记录表头区域高度
int CDrawCurve::GetRecordHeadHig()
{
	int nHig = 0;
	int nCnt = GetDefCheckCnt(m_PrintSet.SumHeadDef);
	nCnt = (nCnt + 1) / 2;
	if (nCnt)
	{
		int nH = int(m_nWordH * 1.5);
		nHig = (nH * nCnt + m_nWordH / 2);
	}
	return nHig;
}

//获取曲线表头高度 表格形式
int CDrawCurve::GetCurveHeadHig()
{
	int nHig = 0;
	int nCnt = GetDefCheckCnt(m_PrintSet.CurveHeadDef);
	nCnt = (nCnt + 1) / 2;
	if (nCnt)
	{
		nHig = nCnt * m_nWordH * 2;
	}
	int nDataCnt = (int)CHZData::GetInstance()->m_vLoadValue.size();
	int nWid = int(m_nWordW / 2);
	int nMaxCnt = int(m_rtPrint.Width() / nWid);
	nMaxCnt -= 2;

	if (m_PrintSet.chSimpleSum && nMaxCnt > 0)
	{
		int nH = 0;
		if (nMaxCnt >= nDataCnt)
		{
			nH = m_nWordH * 2;
		}
		else
		{
			nH = ((nDataCnt + nMaxCnt - 1) / nMaxCnt) * m_nWordH * 2;
		}
		nHig += nH * 2;
		if (m_PrintSet.chSumLoadData)
		{
			nHig += nH;
		}
	}
	return nHig;
}

//获取自定义表头被check个数
int CDrawCurve::GetDefCheckCnt(Print_Def_Head Head)
{
	int nCnt = 0;
	if (Head.bPileNum)
	{
		nCnt++;
	}
	if (Head.bPileJing)
	{
		nCnt++;
	}
	if (Head.bPileLen)
	{
		nCnt++;
	}
	if (Head.bMaxLoad)
	{
		nCnt++;
	}
	if (Head.bLoadGrage)
	{
		nCnt++;
	}
	if (Head.bXunHuanCnt)
	{
		nCnt++;
	}
	if (Head.bTestUnit)
	{
		nCnt++;
	}
	if (Head.bTestDate)
	{
		nCnt++;
	}
	if (Head.bStandard)
	{
		nCnt++;
	}
	if (Head.bYiqiNum)
	{
		nCnt++;
	}
	if (Head.bPileType)
	{
		nCnt++;
	}
	if (Head.bTestType)
	{
		nCnt++;
	}
	if (Head.bJackNum)
	{
		nCnt++;
	}
	if (Head.bJackType)
	{
		nCnt++;
	}
	if (Head.bJackCnt)
	{
		nCnt++;
	}
	if (Head.bWeiyiNum)
	{
		nCnt++;
	}
	if (Head.bWeiyiType)
	{
		nCnt++;
	}
	if (Head.bYaliNum)
	{
		nCnt++;
	}
	if (Head.bYaliType)
	{
		nCnt++;
	}
	if (Head.bPlateType)
	{
		nCnt++;
	}
	if (Head.bPlateArea)
	{
		nCnt++;
	}
	if (Head.bBeizhu)
	{
		nCnt++;
	}
	if (Head.bLoadTime)
	{
		nCnt++;
	}
	if (Head.bLoadoffTime)
	{
		nCnt++;
	}
	if (Head.bTableGap)
	{
		nCnt++;
	}
	return nCnt;
}

